Browse documentationEndpoint reference

Reference

Public endpoint reference

This page is generated from the public registry in packages/contract. An endpoint appears only after its route, authorization requirement, and request and response schemas are ready to support as a developer contract.

api_key means a valid credential. human requires the person's identity, as used by the CLI and dashboard. workspace_member additionally requires membership in the workspace named by the path. Workspace capabilities come from a human's current role or an app credential's explicit declaration. Operations absent from this registry are not a public promise.

Identity

31 operations
POST/v1/workspaces

Create a workspace and begin asynchronous provisioning.

CLI
bento workspace create --body-file request.json
Scope
api_key
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "slug": {
      "type": "string"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    }
  },
  "required": [
    "slug",
    "name"
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspaceId": {
      "type": "string"
    },
    "slug": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "const": "provisioning"
    }
  },
  "required": [
    "workspaceId",
    "slug",
    "status"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/reprovision

Replace an owner-managed workspace runtime after an explicit recovery request.

CLI
bento workspace reprovision
Scope
ws:{workspaceSlug}:admin
Request
No request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "backup_pending"
        },
        "workspaceId": {
          "type": "string"
        },
        "backupId": {
          "type": "string"
        }
      },
      "required": [
        "status",
        "workspaceId",
        "backupId"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "provisioning"
        },
        "workspaceId": {
          "type": "string"
        },
        "scheduled": {
          "type": "boolean"
        },
        "oldVmName": {
          "type": "string"
        },
        "imageRef": {
          "type": "string"
        }
      },
      "required": [
        "status",
        "workspaceId",
        "scheduled"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "const": "deferred"
        },
        "reason": {
          "type": "string",
          "const": "active_workspace_work"
        },
        "activeAgentSessions": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "activeTrainJobs": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "status",
        "reason",
        "activeAgentSessions",
        "activeTrainJobs"
      ],
      "additionalProperties": false
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
DELETE/v1/workspaces/{workspaceSlug}

Permanently delete a workspace after confirming its current slug.

CLI
bento workspace delete --confirmation example
Scope
ws:{workspaceSlug}:admin
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "confirmation": {
      "type": "string"
    }
  },
  "required": [
    "confirmation"
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "deleted": {
      "type": "boolean",
      "const": true
    }
  },
  "required": [
    "deleted"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
PATCH/v1/workspaces/{workspaceSlug}

Update workspace configuration, suspension, or its acknowledged public address.

CLI
bento workspace update --body-file request.json
Scope
ws:{workspaceSlug}:admin
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "slug": {
      "type": "string"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "publicUrlBreakAcknowledged": {
      "type": "boolean",
      "const": true
    },
    "defaultModel": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "suspended": {
      "type": "boolean"
    },
    "suspensionReason": {
      "type": "string"
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspace": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "slug": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "status": {
              "type": "string",
              "enum": [
                "provisioning",
                "active",
                "unhealthy",
                "archived",
                "retired",
                "deleted"
              ]
            },
            "servicingStatus": {
              "type": "string",
              "enum": [
                "active",
                "paused",
                "banned"
              ]
            },
            "servicingPauseReason": {
              "type": "string",
              "enum": [
                "subscription",
                "storage"
              ]
            },
            "servicingStatusChangedAt": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "driveRecovery": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "state": {
                      "type": "string",
                      "const": "pending"
                    }
                  },
                  "required": [
                    "state"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "state": {
                      "type": "string",
                      "const": "available"
                    },
                    "expiresAt": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "state"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "state": {
                      "type": "string",
                      "const": "unavailable"
                    }
                  },
                  "required": [
                    "state"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "role": {
              "type": "string",
              "enum": [
                "owner",
                "editor",
                "viewer"
              ]
            },
            "billingUserId": {
              "type": "string"
            },
            "usableStorageGb": {
              "type": "number",
              "minimum": 0
            },
            "funding": {
              "type": "object",
              "properties": {
                "plan": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "starter",
                        "pro",
                        "max"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "active": {
                  "type": "boolean"
                },
                "trialEndsAt": {
                  "type": "integer",
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "plan",
                "active"
              ],
              "additionalProperties": false
            },
            "creditRecovery": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "subscribe",
                    "topup"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "credits": {
              "type": "object",
              "properties": {
                "payerName": {
                  "type": "string"
                },
                "monthly": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "remainingPercent": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "resetsAt": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "remainingPercent"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reserve": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "remainingPercent": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "share": {
                          "type": "number",
                          "exclusiveMinimum": 0,
                          "maximum": 1
                        }
                      },
                      "required": [
                        "remainingPercent",
                        "share"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "payerName",
                "monthly",
                "reserve"
              ],
              "additionalProperties": false
            },
            "defaultTier": {
              "type": "object",
              "properties": {
                "configured": {
                  "type": "string",
                  "enum": [
                    "frontier",
                    "balanced",
                    "economy",
                    "openai-frontier",
                    "openai-max",
                    "anthropic-frontier",
                    "anthropic-max",
                    "anthropic-balanced",
                    "google-recommended",
                    "google-balanced"
                  ]
                },
                "effective": {
                  "type": "string",
                  "enum": [
                    "frontier",
                    "balanced",
                    "economy",
                    "openai-frontier",
                    "openai-max",
                    "anthropic-frontier",
                    "anthropic-max",
                    "anthropic-balanced",
                    "google-recommended",
                    "google-balanced"
                  ]
                }
              },
              "required": [
                "effective"
              ],
              "additionalProperties": false
            },
            "duetName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32,
              "pattern": "^[^[\\]<>`\\p{Cc}]*$"
            },
            "onboardedAt": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "onboarding": {
              "type": "object",
              "properties": {
                "starterAgents": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "starterAgents"
              ],
              "additionalProperties": false
            },
            "adminMessage": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "slug",
            "name",
            "status",
            "servicingStatus",
            "role",
            "billingUserId",
            "usableStorageGb",
            "funding",
            "creditRecovery",
            "defaultTier"
          ],
          "additionalProperties": false
        },
        {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "suspended": {
                  "type": "boolean",
                  "const": true
                },
                "suspendedAt": {
                  "type": "number"
                },
                "suspensionReason": {
                  "type": "string"
                }
              },
              "required": [
                "suspended",
                "suspendedAt"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "suspended": {
                  "type": "boolean",
                  "const": false
                }
              },
              "required": [
                "suspended"
              ],
              "additionalProperties": false
            }
          ]
        }
      ]
    }
  },
  "required": [
    "workspace"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}

Read the workspace identity, configuration and suspension state.

CLI
bento workspace get
Scope
ws:{workspaceSlug}:admin
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspace": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "slug": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "status": {
              "type": "string",
              "enum": [
                "provisioning",
                "active",
                "unhealthy",
                "archived",
                "retired",
                "deleted"
              ]
            },
            "servicingStatus": {
              "type": "string",
              "enum": [
                "active",
                "paused",
                "banned"
              ]
            },
            "servicingPauseReason": {
              "type": "string",
              "enum": [
                "subscription",
                "storage"
              ]
            },
            "servicingStatusChangedAt": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "driveRecovery": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "state": {
                      "type": "string",
                      "const": "pending"
                    }
                  },
                  "required": [
                    "state"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "state": {
                      "type": "string",
                      "const": "available"
                    },
                    "expiresAt": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "state"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "state": {
                      "type": "string",
                      "const": "unavailable"
                    }
                  },
                  "required": [
                    "state"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "role": {
              "type": "string",
              "enum": [
                "owner",
                "editor",
                "viewer"
              ]
            },
            "billingUserId": {
              "type": "string"
            },
            "usableStorageGb": {
              "type": "number",
              "minimum": 0
            },
            "funding": {
              "type": "object",
              "properties": {
                "plan": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "starter",
                        "pro",
                        "max"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "active": {
                  "type": "boolean"
                },
                "trialEndsAt": {
                  "type": "integer",
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "plan",
                "active"
              ],
              "additionalProperties": false
            },
            "creditRecovery": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "subscribe",
                    "topup"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "credits": {
              "type": "object",
              "properties": {
                "payerName": {
                  "type": "string"
                },
                "monthly": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "remainingPercent": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "resetsAt": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "remainingPercent"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reserve": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "remainingPercent": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "share": {
                          "type": "number",
                          "exclusiveMinimum": 0,
                          "maximum": 1
                        }
                      },
                      "required": [
                        "remainingPercent",
                        "share"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "payerName",
                "monthly",
                "reserve"
              ],
              "additionalProperties": false
            },
            "defaultTier": {
              "type": "object",
              "properties": {
                "configured": {
                  "type": "string",
                  "enum": [
                    "frontier",
                    "balanced",
                    "economy",
                    "openai-frontier",
                    "openai-max",
                    "anthropic-frontier",
                    "anthropic-max",
                    "anthropic-balanced",
                    "google-recommended",
                    "google-balanced"
                  ]
                },
                "effective": {
                  "type": "string",
                  "enum": [
                    "frontier",
                    "balanced",
                    "economy",
                    "openai-frontier",
                    "openai-max",
                    "anthropic-frontier",
                    "anthropic-max",
                    "anthropic-balanced",
                    "google-recommended",
                    "google-balanced"
                  ]
                }
              },
              "required": [
                "effective"
              ],
              "additionalProperties": false
            },
            "duetName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32,
              "pattern": "^[^[\\]<>`\\p{Cc}]*$"
            },
            "onboardedAt": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "onboarding": {
              "type": "object",
              "properties": {
                "starterAgents": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "starterAgents"
              ],
              "additionalProperties": false
            },
            "adminMessage": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "slug",
            "name",
            "status",
            "servicingStatus",
            "role",
            "billingUserId",
            "usableStorageGb",
            "funding",
            "creditRecovery",
            "defaultTier"
          ],
          "additionalProperties": false
        },
        {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "suspended": {
                  "type": "boolean",
                  "const": true
                },
                "suspendedAt": {
                  "type": "number"
                },
                "suspensionReason": {
                  "type": "string"
                }
              },
              "required": [
                "suspended",
                "suspendedAt"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "suspended": {
                  "type": "boolean",
                  "const": false
                }
              },
              "required": [
                "suspended"
              ],
              "additionalProperties": false
            }
          ]
        }
      ]
    }
  },
  "required": [
    "workspace"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/members

List current workspace members and the designated payer. search keeps a member only when every word starts a word of their name or email, so adding a word only narrows the results.

CLI
bento member list
Scope
ws:{workspaceSlug}:sessions or ws:{workspaceSlug}:files:read
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "search": {
      "type": "string",
      "minLength": 1,
      "maxLength": 32
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email",
            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "editor",
              "viewer"
            ]
          },
          "isBillingUser": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "email",
          "role",
          "isBillingUser"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
PATCH/v1/workspaces/{workspaceSlug}/members/{memberId}

Change a member role while preserving payer and final-owner invariants.

CLI
bento member update --member-id example --role owner
Scope
ws:{workspaceSlug}:admin
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "role": {
      "type": "string",
      "enum": [
        "owner",
        "editor",
        "viewer"
      ]
    }
  },
  "required": [
    "role"
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "member": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "format": "email",
          "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
        },
        "name": {
          "type": "string"
        },
        "role": {
          "type": "string",
          "enum": [
            "owner",
            "editor",
            "viewer"
          ]
        },
        "isBillingUser": {
          "type": "boolean"
        }
      },
      "required": [
        "id",
        "email",
        "role",
        "isBillingUser"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "member"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
DELETE/v1/workspaces/{workspaceSlug}/members/{memberId}

Remove a member after payer and final-owner checks pass.

CLI
bento member delete --member-id example
Scope
ws:{workspaceSlug}:admin
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "removed": {
      "type": "boolean"
    }
  },
  "required": [
    "removed"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/leave

Leave the workspace after payer and final-owner checks pass.

CLI
bento workspace leave
Scope
ws:{workspaceSlug}:sessions or ws:{workspaceSlug}:files:read
Request
No request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "removed": {
      "type": "boolean"
    }
  },
  "required": [
    "removed"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/whoami

Inspect the authenticated user, workspace memberships, and granted scopes.

CLI
bento whoami
Scope
api_key
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "format": "email",
          "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "email"
      ],
      "additionalProperties": false
    },
    "workspaces": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "provisioning",
              "active",
              "unhealthy",
              "archived",
              "retired",
              "deleted"
            ]
          },
          "servicingStatus": {
            "type": "string",
            "enum": [
              "active",
              "paused",
              "banned"
            ]
          },
          "servicingPauseReason": {
            "type": "string",
            "enum": [
              "subscription",
              "storage"
            ]
          },
          "servicingStatusChangedAt": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "driveRecovery": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "const": "pending"
                  }
                },
                "required": [
                  "state"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "const": "available"
                  },
                  "expiresAt": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "state"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "const": "unavailable"
                  }
                },
                "required": [
                  "state"
                ],
                "additionalProperties": false
              }
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "editor",
              "viewer"
            ]
          },
          "billingUserId": {
            "type": "string"
          },
          "usableStorageGb": {
            "type": "number",
            "minimum": 0
          },
          "funding": {
            "type": "object",
            "properties": {
              "plan": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "starter",
                      "pro",
                      "max"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "active": {
                "type": "boolean"
              },
              "trialEndsAt": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "plan",
              "active"
            ],
            "additionalProperties": false
          },
          "creditRecovery": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "subscribe",
                  "topup"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "credits": {
            "type": "object",
            "properties": {
              "payerName": {
                "type": "string"
              },
              "monthly": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "remainingPercent": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      "resetsAt": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "remainingPercent"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reserve": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "remainingPercent": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      "share": {
                        "type": "number",
                        "exclusiveMinimum": 0,
                        "maximum": 1
                      }
                    },
                    "required": [
                      "remainingPercent",
                      "share"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "payerName",
              "monthly",
              "reserve"
            ],
            "additionalProperties": false
          },
          "defaultTier": {
            "type": "object",
            "properties": {
              "configured": {
                "type": "string",
                "enum": [
                  "frontier",
                  "balanced",
                  "economy",
                  "openai-frontier",
                  "openai-max",
                  "anthropic-frontier",
                  "anthropic-max",
                  "anthropic-balanced",
                  "google-recommended",
                  "google-balanced"
                ]
              },
              "effective": {
                "type": "string",
                "enum": [
                  "frontier",
                  "balanced",
                  "economy",
                  "openai-frontier",
                  "openai-max",
                  "anthropic-frontier",
                  "anthropic-max",
                  "anthropic-balanced",
                  "google-recommended",
                  "google-balanced"
                ]
              }
            },
            "required": [
              "effective"
            ],
            "additionalProperties": false
          },
          "duetName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "pattern": "^[^[\\]<>`\\p{Cc}]*$"
          },
          "onboardedAt": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "onboarding": {
            "type": "object",
            "properties": {
              "starterAgents": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "starterAgents"
            ],
            "additionalProperties": false
          },
          "adminMessage": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "slug",
          "name",
          "status",
          "servicingStatus",
          "role",
          "billingUserId",
          "usableStorageGb",
          "funding",
          "creditRecovery",
          "defaultTier"
        ],
        "additionalProperties": false
      }
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "versions": {
      "type": "object",
      "properties": {
        "api": {
          "type": "number",
          "const": 1
        }
      },
      "required": [
        "api"
      ],
      "additionalProperties": false
    },
    "internalAdmin": {
      "type": "boolean"
    },
    "credential": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "user",
            "system_vm",
            "app",
            "impersonation",
            "browser_session"
          ]
        }
      },
      "required": [
        "kind"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "user",
    "workspaces",
    "scopes",
    "versions",
    "internalAdmin"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/anchors

List path anchors and their current health.

CLI
bento anchor list
Scope
ws:{workspaceSlug}:files:read
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "app",
              "agent",
              "publish",
              "share-root",
              "share-mount"
            ]
          },
          "settings": {},
          "state": {
            "type": "string",
            "enum": [
              "active",
              "broken",
              "orphaned"
            ]
          },
          "createdAt": {
            "type": "number"
          },
          "updatedAt": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "path",
          "kind",
          "settings",
          "state",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/anchors/{anchorId}/reanchor

Repair a broken anchor after its workspace path moves.

CLI
bento anchor reanchor --anchor-id example --path notes/plan.md
Scope
ws:{workspaceSlug}:apps or ws:{workspaceSlug}:publish or ws:{workspaceSlug}:share
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "path": {
      "type": "string"
    }
  },
  "required": [
    "path"
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "anchor": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "workspaceId": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "app",
            "agent",
            "publish",
            "share-root",
            "share-mount"
          ]
        },
        "settings": {},
        "state": {
          "type": "string",
          "enum": [
            "active",
            "broken",
            "orphaned"
          ]
        },
        "createdAt": {
          "type": "number"
        },
        "updatedAt": {
          "type": "number"
        }
      },
      "required": [
        "id",
        "workspaceId",
        "path",
        "kind",
        "settings",
        "state",
        "createdAt",
        "updatedAt"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "anchor"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/audit

Page through newest-first workspace audit events.

CLI
bento audit list
Scope
ws:{workspaceSlug}:files:read
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "event": {
            "type": "string"
          },
          "actorId": {
            "type": "string"
          },
          "at": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "provenance": {
            "type": "object",
            "properties": {
              "action": {
                "type": "string"
              },
              "activeAgentSessions": {
                "type": "number"
              },
              "activeTrainJobs": {
                "type": "number"
              },
              "actor": {
                "type": "string"
              },
              "acknowledged": {
                "type": "boolean"
              },
              "agentVersion": {
                "type": "string"
              },
              "anchorId": {
                "type": "string"
              },
              "appId": {
                "type": "string"
              },
              "appSlug": {
                "type": "string"
              },
              "agentId": {
                "type": "string"
              },
              "archiveStorageId": {
                "type": "string"
              },
              "withoutArchiveCause": {
                "type": "string"
              },
              "lifecycleBackupId": {
                "type": "string"
              },
              "breaksPublicUrls": {
                "type": "boolean"
              },
              "canonicalEmail": {
                "type": "string"
              },
              "clientName": {
                "type": "string"
              },
              "candidates": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "fromPath": {
                      "type": "string"
                    },
                    "toPath": {
                      "type": "string"
                    },
                    "confidence": {
                      "type": "number"
                    },
                    "inodeMatch": {
                      "type": "boolean"
                    },
                    "markerMatch": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "fromPath",
                    "toPath",
                    "confidence",
                    "inodeMatch",
                    "markerMatch"
                  ],
                  "additionalProperties": false
                }
              },
              "conflictingAnchorId": {
                "type": "string"
              },
              "conflictingPath": {
                "type": "string"
              },
              "confidence": {
                "type": "number"
              },
              "cpu": {
                "type": "number"
              },
              "consecutiveMissingPolls": {
                "type": "number"
              },
              "deleted": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "deviceCode": {
                "type": "string"
              },
              "deviceId": {
                "type": "string"
              },
              "deviceName": {
                "type": "string"
              },
              "defaultModelId": {
                "type": "string"
              },
              "tier": {
                "type": "string",
                "enum": [
                  "frontier",
                  "balanced",
                  "economy",
                  "openai-frontier",
                  "openai-max",
                  "anthropic-frontier",
                  "anthropic-max",
                  "anthropic-balanced",
                  "google-recommended",
                  "google-balanced"
                ]
              },
              "expiresAt": {
                "type": "number"
              },
              "fromPath": {
                "type": "string"
              },
              "fromWorkspaceId": {
                "type": "string"
              },
              "runtimeVersion": {
                "type": "string"
              },
              "gatewayVersion": {
                "type": "string"
              },
              "generation": {
                "type": "string"
              },
              "imageRef": {
                "type": "string"
              },
              "imageVersion": {
                "type": "string"
              },
              "inodeMatch": {
                "type": "boolean"
              },
              "installMode": {
                "type": "string",
                "enum": [
                  "subscribe",
                  "clone_once"
                ]
              },
              "kind": {
                "type": "string",
                "enum": [
                  "app",
                  "agent",
                  "publish",
                  "share-root",
                  "share-mount",
                  "file",
                  "folder"
                ]
              },
              "lastHeartbeatAt": {
                "type": "number"
              },
              "listingId": {
                "type": "string"
              },
              "listingSlug": {
                "type": "string"
              },
              "markerMatch": {
                "type": "boolean"
              },
              "memory": {
                "type": "string"
              },
              "memberUserId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "newBillingUserId": {
                "type": "string"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "read",
                  "write"
                ]
              },
              "mountPath": {
                "type": "string"
              },
              "newSlug": {
                "type": "string"
              },
              "previousStatus": {
                "type": "string"
              },
              "oldPrefixes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "oldBillingUserId": {
                "type": "string"
              },
              "oldSlug": {
                "type": "string"
              },
              "parentShareId": {
                "type": "string"
              },
              "path": {
                "type": "string"
              },
              "prefix": {
                "type": "string"
              },
              "credentialId": {
                "type": "string"
              },
              "purpose": {
                "type": "string",
                "enum": [
                  "managed",
                  "exported"
                ]
              },
              "prefixes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "previousVmName": {
                "type": "string"
              },
              "publishId": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              },
              "revokedShareIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "role": {
                "type": "string",
                "enum": [
                  "owner",
                  "editor",
                  "viewer"
                ]
              },
              "oldRole": {
                "type": "string",
                "enum": [
                  "owner",
                  "editor",
                  "viewer"
                ]
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "sessionId": {
                "type": "string"
              },
              "shareId": {
                "type": "string"
              },
              "slug": {
                "type": "string"
              },
              "source": {
                "type": "string"
              },
              "subscriptionId": {
                "type": "string"
              },
              "targetEmail": {
                "type": "string"
              },
              "toPath": {
                "type": "string"
              },
              "toWorkspaceId": {
                "type": "string"
              },
              "userCode": {
                "type": "string"
              },
              "visibility": {
                "type": "string",
                "enum": [
                  "folder",
                  "public"
                ]
              },
              "vmName": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "event",
          "actorId",
          "at"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/telemetry

Read the workspace VM CPU, memory, and disk telemetry history.

CLI
bento telemetry get
Scope
workspace_member
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "sinceAt": {
      "type": "number",
      "minimum": 0
    }
  }
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "samples": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "at": {
            "type": "number",
            "minimum": 0
          },
          "cpuPct": {
            "type": "number",
            "minimum": 0,
            "maximum": 100
          },
          "memUsedMb": {
            "type": "number",
            "minimum": 0
          },
          "memTotalMb": {
            "type": "number",
            "minimum": 0
          },
          "diskUsedMb": {
            "type": "number",
            "minimum": 0
          },
          "diskTotalMb": {
            "type": "number",
            "minimum": 0
          }
        },
        "required": [
          "at"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "samples"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/user/profile

Read the signed-in user profile.

CLI
bento user profile get
Scope
human
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "email": {
      "type": "string",
      "format": "email",
      "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
    },
    "firstName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    },
    "name": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "email"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
PATCH/v1/user/profile

Update the signed-in user profile.

CLI
bento user profile update
Scope
human
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "maxLength": 100
    },
    "lastName": {
      "type": "string",
      "maxLength": 100
    }
  }
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "email": {
      "type": "string",
      "format": "email",
      "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
    },
    "firstName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    },
    "name": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "email"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/user/api-keys

List ordinary API keys without returning their secrets.

CLI
bento user api-key list
Scope
human
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "createdAt": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "expiresAt": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "lastUsedAt": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "revokedAt": {
            "type": "number",
            "exclusiveMinimum": 0
          }
        },
        "required": [
          "id",
          "prefix",
          "createdAt"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/user/api-keys

Issue a human identity key and reveal its secret once.

CLI
bento user api-key create --body-file request.json
Scope
human
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1
    },
    "expiresAt": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "name"
  ],
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "key": {
      "type": "string"
    },
    "record": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "prefix": {
          "type": "string"
        },
        "createdAt": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "expiresAt": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "lastUsedAt": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "revokedAt": {
          "type": "number",
          "exclusiveMinimum": 0
        }
      },
      "required": [
        "id",
        "prefix",
        "createdAt"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "key",
    "record"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
DELETE/v1/user/api-keys/{apiKeyId}

Revoke one ordinary API key owned by the signed-in user.

CLI
bento user api-key revoke --api-key-id example
Scope
human
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "prefix": {
      "type": "string"
    },
    "revokedAt": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "prefix",
    "revokedAt"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Declared idempotent
PUT/v1/user/push-devices/{installationId}

Register or replace the signed-in user push device.

Scope
human
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "expo_push_token": {
      "type": "string",
      "minLength": 1
    },
    "platform": {
      "type": "string",
      "enum": [
        "ios",
        "android"
      ]
    },
    "app_version": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "expo_push_token",
    "platform",
    "app_version"
  ],
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "installationId": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "ok",
    "installationId"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "human_credential_required",
        "invalid_request"
      ]
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Declared idempotent
DELETE/v1/user/push-devices/{installationId}

Remove one signed-in user push device.

Scope
human
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "installationId": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "ok",
    "installationId"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "human_credential_required"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Declared idempotent
DELETE/v1/user/credential

Revoke the human credential that makes this request.

Scope
human
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "revokedAt": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "revokedAt"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Declared idempotent
POST/v1/user/handoffs

Create a single-use browser handoff URL for the signed-in user.

Scope
human
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "surface": {
          "type": "string",
          "const": "app_shell"
        },
        "app": {
          "type": "object",
          "properties": {
            "platform": {
              "type": "string",
              "enum": [
                "ios",
                "android"
              ]
            },
            "store_country": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[A-Z]{2}$"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "platform",
            "store_country"
          ],
          "additionalProperties": false
        },
        "return_to": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        }
      },
      "required": [
        "surface",
        "app",
        "return_to"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "surface": {
          "type": "string",
          "const": "browser"
        },
        "return_to": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        }
      },
      "required": [
        "surface",
        "return_to"
      ],
      "additionalProperties": false
    }
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "format": "uri"
    },
    "expires_in": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "url",
    "expires_in"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "enum": [
        "human_credential_required",
        "invalid_request",
        "unauthorized"
      ]
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/user/machines

Register a non-secret sync machine for the signed-in user.

CLI
bento user machine create --body-file request.json
Scope
human
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1
    },
    "syncthingDeviceId": {
      "type": "string",
      "pattern": "^[A-Z2-7]{7}(-[A-Z2-7]{7})*$"
    }
  },
  "required": [
    "name",
    "syncthingDeviceId"
  ],
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "machineId": {
      "type": "string",
      "minLength": 1
    },
    "name": {
      "type": "string"
    },
    "syncthingDeviceId": {
      "type": "string",
      "pattern": "^[A-Z2-7]{7}(-[A-Z2-7]{7})*$"
    },
    "createdAt": {
      "type": "number",
      "exclusiveMinimum": 0
    },
    "lastUsedAt": {
      "type": "number",
      "exclusiveMinimum": 0
    },
    "removedAt": {
      "type": "number",
      "exclusiveMinimum": 0
    }
  },
  "required": [
    "machineId",
    "name",
    "syncthingDeviceId",
    "createdAt",
    "lastUsedAt"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Declared idempotent
GET/v1/user/machines

List the signed-in userโ€™s sync machines with creation and last use.

CLI
bento user machine list
Scope
human
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "machineId": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string"
          },
          "syncthingDeviceId": {
            "type": "string",
            "pattern": "^[A-Z2-7]{7}(-[A-Z2-7]{7})*$"
          },
          "createdAt": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "lastUsedAt": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "removedAt": {
            "type": "number",
            "exclusiveMinimum": 0
          }
        },
        "required": [
          "machineId",
          "name",
          "syncthingDeviceId",
          "createdAt",
          "lastUsedAt"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
DELETE/v1/user/machines/{machineId}

Remove one sync machine and detach its workspace mirrors.

CLI
bento user machine delete --machine-id example
Scope
human
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "machineId": {
      "type": "string",
      "minLength": 1
    },
    "removedAt": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "ok",
    "machineId",
    "removedAt"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Declared idempotent
GET/v1/user/invitations

List pending workspace invitations addressed to the signed-in user.

CLI
bento user invitation list
Scope
human
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspace": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "slug": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "name",
              "slug"
            ],
            "additionalProperties": false
          },
          "inviter": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  }
                },
                "required": [
                  "email"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "editor",
              "viewer"
            ]
          },
          "expiresAt": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "id",
          "workspace",
          "inviter",
          "role",
          "expiresAt"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/user/invitations/{invitationId}/accept

Accept an invitation addressed to the signed-in user and return its workspace.

CLI
bento user invitation accept --invitation-id example
Scope
human
Request
No request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspaceId": {
      "type": "string"
    },
    "workspaceSlug": {
      "type": "string"
    }
  },
  "required": [
    "workspaceId",
    "workspaceSlug"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Declared idempotent
POST/v1/workspaces/{workspaceSlug}/invitations

Invite an editor or viewer by canonical email address.

CLI
bento invitation create --body-file request.json
Scope
ws:{workspaceSlug}:members
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "email": {
      "type": "string",
      "format": "email",
      "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
    },
    "role": {
      "description": "Defaults to editor.",
      "type": "string",
      "enum": [
        "editor",
        "viewer"
      ]
    }
  },
  "required": [
    "email"
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "email": {
      "type": "string",
      "format": "email",
      "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
    },
    "role": {
      "type": "string",
      "enum": [
        "editor",
        "viewer"
      ]
    },
    "expiresAt": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "revokedAt": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "consumedAt": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "id",
    "email",
    "role",
    "expiresAt"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/invitations

List recent invitations for a workspace.

CLI
bento invitation list
Scope
ws:{workspaceSlug}:members
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email",
            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
          },
          "role": {
            "type": "string",
            "enum": [
              "editor",
              "viewer"
            ]
          },
          "expiresAt": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "revokedAt": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "consumedAt": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "id",
          "email",
          "role",
          "expiresAt"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
DELETE/v1/workspaces/{workspaceSlug}/invitations/{invitationId}

Revoke an invitation before it is consumed.

CLI
bento invitation revoke --invitation-id example
Scope
ws:{workspaceSlug}:members
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "revokedAt": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "revokedAt"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Declared idempotent

Sessions

30 operations
GET/v1/workspaces/{workspaceSlug}/directory

Read one chunk of the workspace directory snapshot

CLI
bento directory get
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    }
  }
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "highWaterSeq": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "done": {
      "type": "boolean"
    },
    "viewer": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "human"
            },
            "joinedAtSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "kind",
            "joinedAtSeq"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "workspace"
            }
          },
          "required": [
            "kind"
          ],
          "additionalProperties": false
        }
      ]
    },
    "agents": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "anchorId": {
            "type": "string"
          },
          "anchorPath": {
            "type": "string",
            "minLength": 1
          },
          "anchorState": {
            "type": "string",
            "enum": [
              "active",
              "broken",
              "orphaned"
            ]
          },
          "slug": {
            "type": "string"
          },
          "pinned": {
            "type": "boolean"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "pattern": "^[^[\\]<>`\\p{Cc}]*$"
          },
          "icon": {
            "type": "string"
          },
          "sourceShareId": {
            "type": "string"
          },
          "sourceAgentId": {
            "type": "string"
          },
          "listingSubscriptionId": {
            "type": "string"
          },
          "disabledAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "onboardedAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "createdAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "updatedAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "version": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "defaultSessionId": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "anchorId",
          "anchorPath",
          "anchorState",
          "slug",
          "pinned",
          "createdAt",
          "updatedAt",
          "version"
        ],
        "additionalProperties": false
      }
    },
    "rootAgent": {
      "type": "object",
      "properties": {
        "pinned": {
          "type": "boolean"
        },
        "version": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "pinned",
        "version"
      ],
      "additionalProperties": false
    },
    "sessions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "pinned": {
            "type": "boolean"
          },
          "title": {
            "type": "string"
          },
          "titleOrigin": {
            "type": "string",
            "enum": [
              "excerpt",
              "auto",
              "manual"
            ]
          },
          "titleStatus": {
            "type": "string",
            "enum": [
              "generating",
              "complete",
              "failed"
            ]
          },
          "turnStatus": {
            "type": "string",
            "enum": [
              "running",
              "complete",
              "ask",
              "interrupted",
              "sleep"
            ]
          },
          "bucket": {
            "type": "string",
            "enum": [
              "asking",
              "running",
              "scheduled",
              "done"
            ]
          },
          "agent": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "slug": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "name"
            ],
            "additionalProperties": false
          },
          "createdBySessionId": {
            "type": "string"
          },
          "machine": {
            "type": "object",
            "properties": {
              "step": {
                "type": "string"
              },
              "progress": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "total": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "completed",
                  "total"
                ],
                "additionalProperties": false
              },
              "activity": {
                "type": "string",
                "enum": [
                  "running",
                  "sleeping",
                  "waiting",
                  "idle"
                ]
              },
              "nextWakeAt": {
                "type": "number"
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "interrupted",
                  "completed",
                  "failed",
                  "cancelled",
                  "error"
                ]
              }
            },
            "required": [
              "activity"
            ],
            "additionalProperties": false
          },
          "createdAt": {
            "type": "number"
          },
          "updatedAt": {
            "type": "number"
          },
          "lastEventSeq": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "audience": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "workspace"
                  }
                },
                "required": [
                  "kind"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "specific"
                  },
                  "count": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "preview": {
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "memberId": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string",
                          "format": "email",
                          "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "owner",
                            "editor",
                            "viewer"
                          ]
                        }
                      },
                      "required": [
                        "memberId",
                        "userId",
                        "name",
                        "email",
                        "role"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "kind",
                  "count",
                  "preview"
                ],
                "additionalProperties": false
              }
            ]
          },
          "archive": {
            "type": "object",
            "properties": {
              "globalArchivedAt": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "globalArchiveOrigin": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "manual",
                      "automatic"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "personalArchivedAt": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reason": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "global",
                      "personal"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "globalArchivedAt",
              "globalArchiveOrigin",
              "personalArchivedAt",
              "reason"
            ],
            "additionalProperties": false
          },
          "permissions": {
            "type": "object",
            "properties": {
              "send": {
                "type": "boolean"
              },
              "answer": {
                "type": "boolean"
              },
              "interrupt": {
                "type": "boolean"
              },
              "rename": {
                "type": "boolean"
              },
              "pin": {
                "type": "boolean"
              },
              "manageAudience": {
                "type": "boolean"
              },
              "personalArchive": {
                "type": "boolean"
              },
              "globalArchive": {
                "type": "boolean"
              },
              "delete": {
                "type": "boolean"
              }
            },
            "required": [
              "send",
              "answer",
              "interrupt",
              "rename",
              "pin",
              "manageAudience",
              "personalArchive",
              "globalArchive",
              "delete"
            ],
            "additionalProperties": false
          },
          "version": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "activityVersion": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "lastVisibleSeq": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "readThroughSeq": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "isDefault": {
            "type": "boolean"
          },
          "preview": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "minLength": 1
              },
              "author": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "agent"
                      }
                    },
                    "required": [
                      "kind"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "user"
                      },
                      "userId": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "kind",
                      "userId"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "app"
                      },
                      "appId": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "kind",
                      "appId"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "session"
                      },
                      "sessionId": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "kind",
                      "sessionId"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "system"
                      }
                    },
                    "required": [
                      "kind"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            },
            "required": [
              "text",
              "author"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "pinned",
          "title",
          "titleOrigin",
          "titleStatus",
          "turnStatus",
          "bucket",
          "createdAt",
          "updatedAt",
          "lastEventSeq",
          "audience",
          "archive",
          "permissions",
          "version",
          "activityVersion",
          "lastVisibleSeq",
          "isDefault"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "highWaterSeq",
    "nextCursor",
    "done",
    "viewer",
    "sessions"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "invalid_cursor"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "Opaque collection cursor is malformed or bound to another walk (400)"
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "forbidden"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "The caller is not a member of this workspace (403)"
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/directory/events

Stream the workspace directory changes after a sequence, and the events of its running sessions, as server-sent events

Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "after": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    }
  }
}
Headers
  • Last-Event-ID โ€” Resume after this directory sequence; wins over `after`.
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "upsert"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "row": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "pinned": {
                  "type": "boolean"
                },
                "title": {
                  "type": "string"
                },
                "titleOrigin": {
                  "type": "string",
                  "enum": [
                    "excerpt",
                    "auto",
                    "manual"
                  ]
                },
                "titleStatus": {
                  "type": "string",
                  "enum": [
                    "generating",
                    "complete",
                    "failed"
                  ]
                },
                "turnStatus": {
                  "type": "string",
                  "enum": [
                    "running",
                    "complete",
                    "ask",
                    "interrupted",
                    "sleep"
                  ]
                },
                "bucket": {
                  "type": "string",
                  "enum": [
                    "asking",
                    "running",
                    "scheduled",
                    "done"
                  ]
                },
                "agent": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name"
                  ],
                  "additionalProperties": false
                },
                "createdBySessionId": {
                  "type": "string"
                },
                "machine": {
                  "type": "object",
                  "properties": {
                    "step": {
                      "type": "string"
                    },
                    "progress": {
                      "type": "object",
                      "properties": {
                        "completed": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "total": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "completed",
                        "total"
                      ],
                      "additionalProperties": false
                    },
                    "activity": {
                      "type": "string",
                      "enum": [
                        "running",
                        "sleeping",
                        "waiting",
                        "idle"
                      ]
                    },
                    "nextWakeAt": {
                      "type": "number"
                    },
                    "outcome": {
                      "type": "string",
                      "enum": [
                        "interrupted",
                        "completed",
                        "failed",
                        "cancelled",
                        "error"
                      ]
                    }
                  },
                  "required": [
                    "activity"
                  ],
                  "additionalProperties": false
                },
                "createdAt": {
                  "type": "number"
                },
                "updatedAt": {
                  "type": "number"
                },
                "lastEventSeq": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "audience": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "workspace"
                        }
                      },
                      "required": [
                        "kind"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "specific"
                        },
                        "count": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "preview": {
                          "maxItems": 5,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "memberId": {
                                "type": "string"
                              },
                              "userId": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "email": {
                                "type": "string",
                                "format": "email",
                                "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                              },
                              "role": {
                                "type": "string",
                                "enum": [
                                  "owner",
                                  "editor",
                                  "viewer"
                                ]
                              }
                            },
                            "required": [
                              "memberId",
                              "userId",
                              "name",
                              "email",
                              "role"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "kind",
                        "count",
                        "preview"
                      ],
                      "additionalProperties": false
                    }
                  ]
                },
                "archive": {
                  "type": "object",
                  "properties": {
                    "globalArchivedAt": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "globalArchiveOrigin": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "manual",
                            "automatic"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "personalArchivedAt": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reason": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "global",
                            "personal"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "globalArchivedAt",
                    "globalArchiveOrigin",
                    "personalArchivedAt",
                    "reason"
                  ],
                  "additionalProperties": false
                },
                "permissions": {
                  "type": "object",
                  "properties": {
                    "send": {
                      "type": "boolean"
                    },
                    "answer": {
                      "type": "boolean"
                    },
                    "interrupt": {
                      "type": "boolean"
                    },
                    "rename": {
                      "type": "boolean"
                    },
                    "pin": {
                      "type": "boolean"
                    },
                    "manageAudience": {
                      "type": "boolean"
                    },
                    "personalArchive": {
                      "type": "boolean"
                    },
                    "globalArchive": {
                      "type": "boolean"
                    },
                    "delete": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "send",
                    "answer",
                    "interrupt",
                    "rename",
                    "pin",
                    "manageAudience",
                    "personalArchive",
                    "globalArchive",
                    "delete"
                  ],
                  "additionalProperties": false
                },
                "version": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "activityVersion": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "lastVisibleSeq": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "readThroughSeq": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "isDefault": {
                  "type": "boolean"
                },
                "preview": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "string",
                      "minLength": 1
                    },
                    "author": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "agent"
                            }
                          },
                          "required": [
                            "kind"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "user"
                            },
                            "userId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "userId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "app"
                            },
                            "appId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "appId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "session"
                            },
                            "sessionId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "sessionId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "system"
                            }
                          },
                          "required": [
                            "kind"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    }
                  },
                  "required": [
                    "text",
                    "author"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "id",
                "pinned",
                "title",
                "titleOrigin",
                "titleStatus",
                "turnStatus",
                "bucket",
                "createdAt",
                "updatedAt",
                "lastEventSeq",
                "audience",
                "archive",
                "permissions",
                "version",
                "activityVersion",
                "lastVisibleSeq",
                "isDefault"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "kind",
            "seq",
            "row"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "removed"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "sessionId": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "seq",
            "sessionId"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "agent_upsert"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "agent": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "workspaceId": {
                  "type": "string"
                },
                "anchorId": {
                  "type": "string"
                },
                "anchorPath": {
                  "type": "string",
                  "minLength": 1
                },
                "anchorState": {
                  "type": "string",
                  "enum": [
                    "active",
                    "broken",
                    "orphaned"
                  ]
                },
                "slug": {
                  "type": "string"
                },
                "pinned": {
                  "type": "boolean"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 32,
                  "pattern": "^[^[\\]<>`\\p{Cc}]*$"
                },
                "icon": {
                  "type": "string"
                },
                "sourceShareId": {
                  "type": "string"
                },
                "sourceAgentId": {
                  "type": "string"
                },
                "listingSubscriptionId": {
                  "type": "string"
                },
                "disabledAt": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "onboardedAt": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "createdAt": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "updatedAt": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "version": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "defaultSessionId": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "workspaceId",
                "anchorId",
                "anchorPath",
                "anchorState",
                "slug",
                "pinned",
                "createdAt",
                "updatedAt",
                "version"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "kind",
            "seq",
            "agent"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "agent_removed"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "agentId": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "seq",
            "agentId"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "root_agent_upsert"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "rootAgent": {
              "type": "object",
              "properties": {
                "pinned": {
                  "type": "boolean"
                },
                "version": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "pinned",
                "version"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "kind",
            "seq",
            "rootAgent"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "session_read"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "sessionId": {
              "type": "string"
            },
            "readThroughSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "kind",
            "seq",
            "sessionId",
            "readThroughSeq"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "apps_changed"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "kind",
            "seq"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "reset"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "kind",
            "seq"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "cursor"
            },
            "seq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "kind",
            "seq"
          ],
          "additionalProperties": false
        }
      ]
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "session_joined"
        },
        "sessionId": {
          "type": "string"
        },
        "afterSeq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "headSeq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "kind",
        "sessionId",
        "afterSeq",
        "headSeq"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "session_event"
        },
        "sessionId": {
          "type": "string"
        },
        "frame": {
          "type": "object",
          "properties": {
            "seq": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "createdAt": {
              "type": "number"
            },
            "event": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "step"
                            },
                            "step": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call_start"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "isError": {
                                      "type": "boolean"
                                    },
                                    "output": {
                                      "type": "array",
                                      "items": {
                                        "oneOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "text"
                                              },
                                              "text": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "text"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "image"
                                              },
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "details": {}
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId",
                                    "isError"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "system"
                                    },
                                    "message": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "step"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_started"
                            },
                            "task": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "tool",
                                    "subagent",
                                    "scheduled"
                                  ]
                                },
                                "name": {
                                  "type": "string"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "ownerScopeId": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "pattern": "^turn-\\d+$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^task:t\\d+$"
                                    }
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "scheduled",
                                    "completed",
                                    "failed",
                                    "stopped",
                                    "lost"
                                  ]
                                },
                                "startedAt": {
                                  "type": "number"
                                },
                                "wakeAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "id",
                                "kind",
                                "name",
                                "label",
                                "ownerScopeId",
                                "status",
                                "startedAt"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "task"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_output"
                            },
                            "taskId": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "chunk": {
                              "type": "string"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "taskId",
                            "chunk"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_settled"
                            },
                            "settlement": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "completed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "result": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "result"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "failed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "error": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "error"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "stopped"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "reason": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "reason"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "lost"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "settlement"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "heartbeat"
                            },
                            "timestamp": {
                              "type": "number"
                            },
                            "activeTaskIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            }
                          },
                          "required": [
                            "type",
                            "timestamp",
                            "activeTaskIds"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "todos"
                            },
                            "todos": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "in_progress",
                                      "completed",
                                      "failed"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "content",
                                  "status"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "todos"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "follow_up_queue"
                            },
                            "followUpQueue": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "message"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "followUpQueue"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "state_machine"
                            },
                            "stateMachine": {
                              "type": "object",
                              "properties": {
                                "definition": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "states": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "prompt",
                                    "states"
                                  ],
                                  "additionalProperties": false
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "currentState": {
                                  "type": "string"
                                },
                                "currentInput": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "progress": {
                                  "type": "object",
                                  "properties": {
                                    "states": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "states"
                                  ],
                                  "additionalProperties": {}
                                },
                                "history": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "terminal": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "terminalAcknowledged": {
                                  "type": "boolean"
                                },
                                "createdAt": {
                                  "type": "number"
                                },
                                "updatedAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "definition",
                                "prompt",
                                "history",
                                "createdAt",
                                "updatedAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "stateMachine"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "memory"
                            },
                            "phase": {
                              "type": "string",
                              "enum": [
                                "observation",
                                "reflection"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "completed"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "observations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "usageBumpedObservations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "type",
                            "phase",
                            "status",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "usage"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "turnUsage",
                            "usageByModel",
                            "lastMessageUsage",
                            "effectiveContextWindow",
                            "contextWindowUsage"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "system"
                            },
                            "level": {
                              "type": "string",
                              "enum": [
                                "debug",
                                "info",
                                "warn",
                                "error"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "providerRecovery": {
                              "type": "object",
                              "properties": {
                                "fromModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "fromRoute": {
                                  "type": "string",
                                  "enum": [
                                    "configured",
                                    "vercel",
                                    "unknown"
                                  ]
                                },
                                "toModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "toRoute": {
                                  "type": "string",
                                  "const": "vercel"
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "empty_response",
                                    "provider_error"
                                  ]
                                },
                                "status": {
                                  "type": "integer",
                                  "minimum": 100,
                                  "maximum": 599
                                }
                              },
                              "required": [
                                "fromModel",
                                "fromRoute",
                                "toModel",
                                "toRoute",
                                "reason"
                              ],
                              "additionalProperties": false
                            },
                            "metadata": {
                              "type": "object",
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "enum": [
                                    "storage_full",
                                    "session_cwd_fallback",
                                    "bound_agent_root_unavailable",
                                    "relay_backlog",
                                    "runner_exited",
                                    "relay_undeliverable",
                                    "interrupt_undeliverable"
                                  ]
                                }
                              },
                              "required": [
                                "code"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "level",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "router_switch"
                            },
                            "tier": {
                              "type": "string"
                            },
                            "route": {
                              "type": "string"
                            },
                            "fromModel": {
                              "type": "string"
                            },
                            "toModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            },
                            "trigger": {
                              "type": "string",
                              "enum": [
                                "first_turn",
                                "new_task",
                                "idle",
                                "manual_compact",
                                "overflow",
                                "modality_switch",
                                "tier_change"
                              ]
                            },
                            "rationale": {
                              "type": "string"
                            },
                            "probabilities": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "visionFallback": {
                              "type": "boolean"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "tier",
                            "route",
                            "fromModel",
                            "toModel",
                            "thinkingLevel",
                            "trigger",
                            "visionFallback"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "status"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "quiet": {
                              "type": "boolean",
                              "const": true
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "status": {
                              "type": "string",
                              "const": "ask"
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "status": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "status": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "session_created"
                        },
                        "prompt": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "clientRequestId": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "required": [
                        "type",
                        "prompt",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "interrupt_requested"
                        },
                        "requestedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "requestedAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "agent_message"
                        },
                        "message": {
                          "type": "string",
                          "minLength": 1
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "view_shown"
                        },
                        "view": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "view",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "prompt_submitted"
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "inputKind": {
                              "type": "string",
                              "enum": [
                                "initial",
                                "message"
                              ]
                            },
                            "behavior": {
                              "type": "string",
                              "enum": [
                                "steer",
                                "follow_up"
                              ]
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "prompt",
                            "inputKind",
                            "behavior",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "note_submitted"
                            },
                            "note": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "note",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "answer_submitted"
                            },
                            "answer": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "answer",
                            "sender"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    }
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": {}
                }
              ]
            }
          },
          "required": [
            "event"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "kind",
        "sessionId",
        "frame"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "enum": [
            "forbidden",
            "unavailable"
          ]
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false
    }
  ]
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "invalid_last_event_id"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "`Last-Event-ID` is not a directory sequence (400)"
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "forbidden"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "The caller is not a member of this workspace (403)"
    }
  ]
}
Delivery
Server-sent event stream
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions

List and page sessions by bucket. search keeps a session only when every word appears in its title or first prompt, so adding a word only narrows the results.

CLI
bento session list
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "bucket": {
      "type": "string",
      "enum": [
        "asking",
        "running",
        "scheduled",
        "done"
      ]
    },
    "archived": {
      "default": "exclude",
      "type": "string",
      "enum": [
        "exclude",
        "only"
      ]
    },
    "search": {
      "type": "string",
      "maxLength": 200
    },
    "agentId": {
      "type": "string",
      "minLength": 1
    },
    "excludeDefault": {
      "anyOf": [
        {
          "type": "boolean",
          "const": true
        },
        {
          "type": "string",
          "const": "true"
        }
      ]
    },
    "topLevel": {
      "anyOf": [
        {
          "type": "boolean",
          "const": true
        },
        {
          "type": "string",
          "const": "true"
        }
      ]
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "pinned": {
            "type": "boolean"
          },
          "pin": {
            "type": "object",
            "properties": {
              "pinned": {
                "type": "boolean"
              },
              "version": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "pinned",
              "version"
            ],
            "additionalProperties": false
          },
          "turnStatus": {
            "type": "string",
            "enum": [
              "running",
              "complete",
              "ask",
              "interrupted",
              "sleep"
            ]
          },
          "turnError": {
            "type": "string"
          },
          "bucket": {
            "type": "string",
            "enum": [
              "asking",
              "running",
              "scheduled",
              "done"
            ]
          },
          "title": {
            "type": "string"
          },
          "titleOrigin": {
            "type": "string",
            "enum": [
              "excerpt",
              "auto",
              "manual"
            ]
          },
          "titleStatus": {
            "type": "string",
            "enum": [
              "generating",
              "complete",
              "failed"
            ]
          },
          "cwd": {
            "type": "string"
          },
          "agent": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "slug": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "name"
            ],
            "additionalProperties": false
          },
          "onboarding": {
            "type": "boolean"
          },
          "createdBySessionId": {
            "type": "string"
          },
          "createdAt": {
            "type": "number"
          },
          "updatedAt": {
            "type": "number"
          },
          "lastEventSeq": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "unread": {
            "type": "boolean"
          },
          "audience": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "workspace"
                  }
                },
                "required": [
                  "kind"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "specific"
                  },
                  "count": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "preview": {
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "memberId": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string",
                          "format": "email",
                          "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "owner",
                            "editor",
                            "viewer"
                          ]
                        }
                      },
                      "required": [
                        "memberId",
                        "userId",
                        "name",
                        "email",
                        "role"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "kind",
                  "count",
                  "preview"
                ],
                "additionalProperties": false
              }
            ]
          },
          "archive": {
            "type": "object",
            "properties": {
              "globalArchivedAt": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "globalArchiveOrigin": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "manual",
                      "automatic"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "personalArchivedAt": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reason": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "global",
                      "personal"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "globalArchivedAt",
              "globalArchiveOrigin",
              "personalArchivedAt",
              "reason"
            ],
            "additionalProperties": false
          },
          "permissions": {
            "type": "object",
            "properties": {
              "send": {
                "type": "boolean"
              },
              "answer": {
                "type": "boolean"
              },
              "interrupt": {
                "type": "boolean"
              },
              "rename": {
                "type": "boolean"
              },
              "pin": {
                "type": "boolean"
              },
              "manageAudience": {
                "type": "boolean"
              },
              "personalArchive": {
                "type": "boolean"
              },
              "globalArchive": {
                "type": "boolean"
              },
              "delete": {
                "type": "boolean"
              }
            },
            "required": [
              "send",
              "answer",
              "interrupt",
              "rename",
              "pin",
              "manageAudience",
              "personalArchive",
              "globalArchive",
              "delete"
            ],
            "additionalProperties": false
          },
          "view": {
            "type": "string"
          },
          "viewRevision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "viewBy": {
            "type": "string",
            "enum": [
              "user",
              "agent"
            ]
          },
          "machine": {
            "type": "object",
            "properties": {
              "step": {
                "type": "string"
              },
              "progress": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "total": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "completed",
                  "total"
                ],
                "additionalProperties": false
              },
              "activity": {
                "type": "string",
                "enum": [
                  "running",
                  "sleeping",
                  "waiting",
                  "idle"
                ]
              },
              "nextWakeAt": {
                "type": "number"
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "interrupted",
                  "completed",
                  "failed",
                  "cancelled",
                  "error"
                ]
              }
            },
            "required": [
              "activity"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "pinned",
          "turnStatus",
          "bucket",
          "title",
          "titleOrigin",
          "titleStatus",
          "createdAt",
          "updatedAt",
          "lastEventSeq",
          "unread",
          "audience",
          "archive",
          "permissions"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions/search

Search the messages of every session you can see with a regular expression. Sessions come back best match first, each with its matching messages as snippets; open a match in context with session.history.list from its seq. The pattern is a JavaScript RegExp with the `u` flag, which differs from ripgrep: \w, \d and \b are ASCII-only, and there is no leading (?i). fixedStrings matches the pattern as plain text. Case follows smart case: case-insensitive unless the pattern spells an uppercase letter; caseSensitive overrides it. An index finds candidates by words, from the start of a word only, so the pattern must require a word that starts a word in the text: "ploy" does not find "deploy", and a pattern with no such word (\d{3}) is refused unless sessionId names one session to read whole. A word longer than 31 UTF-8 bytes is found by its first 31 bytes only, and near that cut a letter shorter lowercased than as written (the Kelvin sign, ฤฐ) can miss. Case-insensitive search finds a word by its lowercase spelling, so letters JavaScript treats as one (ฯƒ/ฯ‚, s/ลฟ, ยต/ฮผ) are different to the index. Long messages are indexed in chunks of about 8 KiB, and a match that spans two chunks can be missed. Only text a reader sees by default is searched: messages and the questions an agent asks, not tool calls, tool output, reasoning or attachments. meta.complete is false when a page may be missing matches, usually because a common word filled the read budget (reason read_budget); narrow the search as meta.hint says.

CLI
bento session search --pattern 'webhook.*retr' --from user --created-after 2026-10-01
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "pattern": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000,
      "description": "A JavaScript regular expression, compiled with the u flag; at most 1,000 characters."
    },
    "fixedStrings": {
      "description": "Match the pattern as plain text, not a regex.",
      "type": "boolean"
    },
    "caseSensitive": {
      "description": "Omitted: smart case, so the search is case-sensitive only when the pattern spells an uppercase letter.",
      "type": "boolean"
    },
    "agentId": {
      "description": "Only sessions of this agent; `root` for the drive's own sessions.",
      "type": "string",
      "minLength": 1
    },
    "sessionId": {
      "description": "Only this session, read whole, so the pattern needs no required word.",
      "type": "string",
      "minLength": 1
    },
    "from": {
      "description": "Only messages from this side.",
      "type": "string",
      "enum": [
        "user",
        "assistant"
      ]
    },
    "createdAfter": {
      "description": "Only messages created after this instant: an ISO date (midnight UTC) or date-time.",
      "type": "string"
    },
    "createdBefore": {
      "description": "Only messages created before this instant: an ISO date (midnight UTC) or date-time.",
      "type": "string"
    },
    "archived": {
      "default": "include",
      "description": "Whether archived sessions are searched too, left out, or searched alone.",
      "type": "string",
      "enum": [
        "include",
        "exclude",
        "only"
      ]
    }
  },
  "required": [
    "pattern"
  ],
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "session": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "pinned": {
                "type": "boolean"
              },
              "pin": {
                "type": "object",
                "properties": {
                  "pinned": {
                    "type": "boolean"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "pinned",
                  "version"
                ],
                "additionalProperties": false
              },
              "turnStatus": {
                "type": "string",
                "enum": [
                  "running",
                  "complete",
                  "ask",
                  "interrupted",
                  "sleep"
                ]
              },
              "turnError": {
                "type": "string"
              },
              "bucket": {
                "type": "string",
                "enum": [
                  "asking",
                  "running",
                  "scheduled",
                  "done"
                ]
              },
              "title": {
                "type": "string"
              },
              "titleOrigin": {
                "type": "string",
                "enum": [
                  "excerpt",
                  "auto",
                  "manual"
                ]
              },
              "titleStatus": {
                "type": "string",
                "enum": [
                  "generating",
                  "complete",
                  "failed"
                ]
              },
              "cwd": {
                "type": "string"
              },
              "agent": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "slug": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name"
                ],
                "additionalProperties": false
              },
              "onboarding": {
                "type": "boolean"
              },
              "createdBySessionId": {
                "type": "string"
              },
              "createdAt": {
                "type": "number"
              },
              "updatedAt": {
                "type": "number"
              },
              "lastEventSeq": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "unread": {
                "type": "boolean"
              },
              "audience": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "workspace"
                      }
                    },
                    "required": [
                      "kind"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "specific"
                      },
                      "count": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "preview": {
                        "maxItems": 5,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "memberId": {
                              "type": "string"
                            },
                            "userId": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "email": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "role": {
                              "type": "string",
                              "enum": [
                                "owner",
                                "editor",
                                "viewer"
                              ]
                            }
                          },
                          "required": [
                            "memberId",
                            "userId",
                            "name",
                            "email",
                            "role"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "kind",
                      "count",
                      "preview"
                    ],
                    "additionalProperties": false
                  }
                ]
              },
              "archive": {
                "type": "object",
                "properties": {
                  "globalArchivedAt": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "globalArchiveOrigin": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "manual",
                          "automatic"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "personalArchivedAt": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "global",
                          "personal"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "globalArchivedAt",
                  "globalArchiveOrigin",
                  "personalArchivedAt",
                  "reason"
                ],
                "additionalProperties": false
              },
              "permissions": {
                "type": "object",
                "properties": {
                  "send": {
                    "type": "boolean"
                  },
                  "answer": {
                    "type": "boolean"
                  },
                  "interrupt": {
                    "type": "boolean"
                  },
                  "rename": {
                    "type": "boolean"
                  },
                  "pin": {
                    "type": "boolean"
                  },
                  "manageAudience": {
                    "type": "boolean"
                  },
                  "personalArchive": {
                    "type": "boolean"
                  },
                  "globalArchive": {
                    "type": "boolean"
                  },
                  "delete": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "send",
                  "answer",
                  "interrupt",
                  "rename",
                  "pin",
                  "manageAudience",
                  "personalArchive",
                  "globalArchive",
                  "delete"
                ],
                "additionalProperties": false
              },
              "view": {
                "type": "string"
              },
              "viewRevision": {
                "type": "integer",
                "minimum": 1,
                "maximum": 9007199254740991
              },
              "viewBy": {
                "type": "string",
                "enum": [
                  "user",
                  "agent"
                ]
              },
              "machine": {
                "type": "object",
                "properties": {
                  "step": {
                    "type": "string"
                  },
                  "progress": {
                    "type": "object",
                    "properties": {
                      "completed": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "total": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "completed",
                      "total"
                    ],
                    "additionalProperties": false
                  },
                  "activity": {
                    "type": "string",
                    "enum": [
                      "running",
                      "sleeping",
                      "waiting",
                      "idle"
                    ]
                  },
                  "nextWakeAt": {
                    "type": "number"
                  },
                  "outcome": {
                    "type": "string",
                    "enum": [
                      "interrupted",
                      "completed",
                      "failed",
                      "cancelled",
                      "error"
                    ]
                  }
                },
                "required": [
                  "activity"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "id",
              "pinned",
              "turnStatus",
              "bucket",
              "title",
              "titleOrigin",
              "titleStatus",
              "createdAt",
              "updatedAt",
              "lastEventSeq",
              "unread",
              "audience",
              "archive",
              "permissions"
            ],
            "additionalProperties": false
          },
          "matches": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "seq": {
                  "type": "integer",
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991
                },
                "createdAt": {
                  "type": "number"
                },
                "author": {
                  "type": "string",
                  "enum": [
                    "user",
                    "assistant"
                  ]
                },
                "sender": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "user"
                        },
                        "userId": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "kind",
                        "userId"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "app"
                        },
                        "appId": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "kind",
                        "appId"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "session"
                        },
                        "sessionId": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "kind",
                        "sessionId"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "system"
                        }
                      },
                      "required": [
                        "kind"
                      ],
                      "additionalProperties": false
                    }
                  ]
                },
                "snippet": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "string"
                    },
                    "highlights": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "prefixItems": [
                          {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          }
                        ]
                      }
                    }
                  },
                  "required": [
                    "text",
                    "highlights"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "seq",
                "createdAt",
                "author",
                "snippet"
              ],
              "additionalProperties": false
            }
          },
          "moreMatches": {
            "type": "boolean"
          }
        },
        "required": [
          "session",
          "matches",
          "moreMatches"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "meta": {
      "type": "object",
      "properties": {
        "complete": {
          "type": "boolean"
        },
        "reason": {
          "type": "string",
          "enum": [
            "candidate_cap",
            "read_budget",
            "access_filtered"
          ]
        },
        "hint": {
          "type": "string"
        }
      },
      "required": [
        "complete"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "anyOf": [
        {
          "anyOf": [
            {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "pattern_invalid"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "message"
                  ],
                  "additionalProperties": false,
                  "description": "The pattern is not a valid JavaScript regular expression in `u` mode (400)"
                },
                {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "pattern_needs_literal"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false,
                  "description": "The pattern has no word every match must contain. Add one, or search one session with sessionId (400)."
                }
              ]
            },
            {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "pattern_too_expensive"
                }
              },
              "required": [
                "error"
              ],
              "additionalProperties": false,
              "description": "The pattern needs more alternatives than one search can run (over 16 words), or took over a second to check. Use fewer alternatives, a simpler pattern, narrower filters, or sessionId (400)."
            }
          ]
        },
        {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "const": "not_found"
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false,
          "description": "The session is unavailable to this caller (404)"
        }
      ]
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "invalid_cursor"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "Opaque collection cursor is malformed or bound to another walk (400)"
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/skills

List the skills available to a session working in a workspace folder

CLI
bento skill list
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "cwd": {
      "type": "string"
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string"
          },
          "path": {
            "type": "string",
            "minLength": 1
          },
          "scope": {
            "type": "string",
            "enum": [
              "user",
              "project",
              "temporary",
              "builtin"
            ]
          }
        },
        "required": [
          "name",
          "path"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/sessions

Create a session from its first user message

CLI
bento session create --agent seo-specialist --title "heybento.ai" --prompt "..."
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "prompt": {
          "type": "string",
          "description": "The words of the input. May be empty when it carries images or attachments."
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "clientRequestId": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "agent": {
          "description": "The agent that owns the session, by slug; `root` is the workspace agent. The session runs in the agent's folder. Not with cwd.",
          "type": "string"
        },
        "cwd": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
        },
        "images": {
          "maxItems": 4,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "data": {
                "type": "string",
                "minLength": 1
              },
              "mimeType": {
                "type": "string",
                "enum": [
                  "image/png",
                  "image/jpeg",
                  "image/webp",
                  "image/gif"
                ]
              }
            },
            "required": [
              "data",
              "mimeType"
            ]
          }
        },
        "attachments": {
          "maxItems": 10,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string",
                "minLength": 1
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 255
              },
              "bytes": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "mimeType": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "path",
              "name",
              "bytes"
            ]
          }
        },
        "dictated": {
          "description": "True when the words were transcribed from speech.",
          "type": "boolean"
        },
        "tier": {
          "type": "string",
          "enum": [
            "frontier",
            "balanced",
            "economy",
            "openai-frontier",
            "openai-max",
            "anthropic-frontier",
            "anthropic-max",
            "anthropic-balanced",
            "google-recommended",
            "google-balanced"
          ]
        },
        "behavior": {
          "default": "steer",
          "type": "string",
          "enum": [
            "steer",
            "follow_up"
          ]
        },
        "mode": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "prompt": {
              "type": "string"
            },
            "states": {
              "type": "array",
              "items": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              }
            }
          },
          "required": [
            "name",
            "prompt",
            "states"
          ]
        },
        "audience": {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "specific"
            },
            "memberUserIds": {
              "maxItems": 100,
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "required": [
            "kind",
            "memberUserIds"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "prompt"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "onboarding"
        },
        "agentSlug": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "agentSlug"
      ],
      "additionalProperties": false
    }
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "session": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string"
            },
            "status": {
              "type": "string",
              "enum": [
                "running",
                "complete",
                "ask",
                "interrupted",
                "sleep"
              ]
            },
            "lastEventSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "lastDeliveredInputSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "sessionId",
            "status",
            "lastEventSeq",
            "lastDeliveredInputSeq"
          ],
          "additionalProperties": false
        },
        "snapshot": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "pinned": {
              "type": "boolean"
            },
            "pin": {
              "type": "object",
              "properties": {
                "pinned": {
                  "type": "boolean"
                },
                "version": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "pinned",
                "version"
              ],
              "additionalProperties": false
            },
            "turnStatus": {
              "type": "string",
              "enum": [
                "running",
                "complete",
                "ask",
                "interrupted",
                "sleep"
              ]
            },
            "turnError": {
              "type": "string"
            },
            "bucket": {
              "type": "string",
              "enum": [
                "asking",
                "running",
                "scheduled",
                "done"
              ]
            },
            "title": {
              "type": "string"
            },
            "titleOrigin": {
              "type": "string",
              "enum": [
                "excerpt",
                "auto",
                "manual"
              ]
            },
            "titleStatus": {
              "type": "string",
              "enum": [
                "generating",
                "complete",
                "failed"
              ]
            },
            "cwd": {
              "type": "string"
            },
            "agent": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ],
              "additionalProperties": false
            },
            "onboarding": {
              "type": "boolean"
            },
            "createdBySessionId": {
              "type": "string"
            },
            "machine": {
              "type": "object",
              "properties": {
                "definitionName": {
                  "type": "string"
                },
                "currentState": {
                  "type": "string"
                },
                "followingDefinitionState": {
                  "type": "string"
                },
                "progress": {
                  "type": "object",
                  "properties": {
                    "completed": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "total": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "completed",
                    "total"
                  ],
                  "additionalProperties": false
                },
                "orderedPath": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "index": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "name": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string"
                      },
                      "phase": {
                        "type": "string",
                        "enum": [
                          "past",
                          "current",
                          "future",
                          "outcome"
                        ]
                      },
                      "terminalStatus": {
                        "type": "string",
                        "enum": [
                          "completed",
                          "failed",
                          "cancelled",
                          "error"
                        ]
                      }
                    },
                    "required": [
                      "key",
                      "index",
                      "name",
                      "phase"
                    ],
                    "additionalProperties": false
                  }
                },
                "activity": {
                  "type": "string",
                  "enum": [
                    "running",
                    "sleeping",
                    "waiting",
                    "idle"
                  ]
                },
                "nextWakeAt": {
                  "type": "number"
                },
                "pollIntervalMs": {
                  "type": "number"
                },
                "outcome": {
                  "type": "string",
                  "enum": [
                    "interrupted",
                    "completed",
                    "failed",
                    "cancelled",
                    "error"
                  ]
                }
              },
              "required": [
                "orderedPath",
                "activity"
              ],
              "additionalProperties": false
            },
            "createdAt": {
              "type": "number"
            },
            "updatedAt": {
              "type": "number"
            },
            "lastEventSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "unread": {
              "type": "boolean"
            },
            "audience": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "workspace"
                    }
                  },
                  "required": [
                    "kind"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "specific"
                    },
                    "count": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "preview": {
                      "maxItems": 5,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "memberId": {
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "role": {
                            "type": "string",
                            "enum": [
                              "owner",
                              "editor",
                              "viewer"
                            ]
                          }
                        },
                        "required": [
                          "memberId",
                          "userId",
                          "name",
                          "email",
                          "role"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "kind",
                    "count",
                    "preview"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "archive": {
              "type": "object",
              "properties": {
                "globalArchivedAt": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "globalArchiveOrigin": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "manual",
                        "automatic"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "personalArchivedAt": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reason": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "global",
                        "personal"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "globalArchivedAt",
                "globalArchiveOrigin",
                "personalArchivedAt",
                "reason"
              ],
              "additionalProperties": false
            },
            "permissions": {
              "type": "object",
              "properties": {
                "send": {
                  "type": "boolean"
                },
                "answer": {
                  "type": "boolean"
                },
                "interrupt": {
                  "type": "boolean"
                },
                "rename": {
                  "type": "boolean"
                },
                "pin": {
                  "type": "boolean"
                },
                "manageAudience": {
                  "type": "boolean"
                },
                "personalArchive": {
                  "type": "boolean"
                },
                "globalArchive": {
                  "type": "boolean"
                },
                "delete": {
                  "type": "boolean"
                }
              },
              "required": [
                "send",
                "answer",
                "interrupt",
                "rename",
                "pin",
                "manageAudience",
                "personalArchive",
                "globalArchive",
                "delete"
              ],
              "additionalProperties": false
            },
            "view": {
              "type": "string"
            },
            "viewRevision": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "viewBy": {
              "type": "string",
              "enum": [
                "user",
                "agent"
              ]
            },
            "workspaceId": {
              "type": "string"
            },
            "tier": {
              "type": "string",
              "enum": [
                "frontier",
                "balanced",
                "economy",
                "openai-frontier",
                "openai-max",
                "anthropic-frontier",
                "anthropic-max",
                "anthropic-balanced",
                "google-recommended",
                "google-balanced"
              ]
            },
            "lastDeliveredInputSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "deliveryAttempt": {
              "type": "object",
              "properties": {
                "attemptId": {
                  "type": "string",
                  "minLength": 1
                },
                "throughSeq": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "initial_prompt",
                    "message",
                    "answer"
                  ]
                },
                "createdAt": {
                  "type": "number"
                }
              },
              "required": [
                "attemptId",
                "throughSeq",
                "kind",
                "createdAt"
              ],
              "additionalProperties": false
            },
            "todos": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "in_progress",
                      "completed",
                      "failed"
                    ]
                  }
                },
                "required": [
                  "id",
                  "content",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "followUpQueue": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "string"
                        },
                        "mimeType": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "data",
                        "mimeType"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "message"
                ],
                "additionalProperties": false
              }
            },
            "requestedMachine": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "prompt": {
                  "type": "string"
                },
                "states": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                }
              },
              "required": [
                "name",
                "prompt",
                "states"
              ],
              "additionalProperties": false
            },
            "machineState": {
              "type": "object",
              "properties": {
                "definition": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "prompt": {
                      "type": "string"
                    },
                    "states": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "name",
                    "prompt",
                    "states"
                  ],
                  "additionalProperties": false
                },
                "prompt": {
                  "type": "string"
                },
                "currentState": {
                  "type": "string"
                },
                "currentInput": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "progress": {
                  "type": "object",
                  "properties": {
                    "states": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "states"
                  ],
                  "additionalProperties": {}
                },
                "history": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "terminal": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "terminalAcknowledged": {
                  "type": "boolean"
                },
                "createdAt": {
                  "type": "number"
                },
                "updatedAt": {
                  "type": "number"
                }
              },
              "required": [
                "definition",
                "prompt",
                "history",
                "createdAt",
                "updatedAt"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "id",
            "pinned",
            "turnStatus",
            "bucket",
            "title",
            "titleOrigin",
            "titleStatus",
            "createdAt",
            "updatedAt",
            "lastEventSeq",
            "unread",
            "audience",
            "archive",
            "permissions",
            "workspaceId",
            "lastDeliveredInputSeq"
          ],
          "additionalProperties": false
        },
        "history": {
          "type": "object",
          "properties": {
            "events": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "seq": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "event": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "turn_started"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "step"
                                  },
                                  "step": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "text_delta"
                                          },
                                          "delta": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "delta"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "reasoning_delta"
                                          },
                                          "delta": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "delta"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "text"
                                          },
                                          "text": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "text"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "reasoning"
                                          },
                                          "text": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "text"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "tool_call_start"
                                          },
                                          "toolName": {
                                            "type": "string"
                                          },
                                          "toolCallId": {
                                            "type": "string"
                                          },
                                          "input": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "toolName",
                                          "toolCallId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "tool_call"
                                          },
                                          "toolName": {
                                            "type": "string"
                                          },
                                          "toolCallId": {
                                            "type": "string"
                                          },
                                          "input": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "isError": {
                                            "type": "boolean"
                                          },
                                          "output": {
                                            "type": "array",
                                            "items": {
                                              "oneOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "const": "text"
                                                    },
                                                    "text": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "type",
                                                    "text"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "const": "image"
                                                    },
                                                    "data": {
                                                      "type": "string"
                                                    },
                                                    "mimeType": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "type",
                                                    "data",
                                                    "mimeType"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "details": {}
                                        },
                                        "required": [
                                          "type",
                                          "toolName",
                                          "toolCallId",
                                          "isError"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "system"
                                          },
                                          "message": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "step"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "task_started"
                                  },
                                  "task": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "task"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "task_output"
                                  },
                                  "taskId": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "chunk": {
                                    "type": "string"
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "taskId",
                                  "chunk"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "task_settled"
                                  },
                                  "settlement": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "pattern": "^t\\d+$"
                                          },
                                          "status": {
                                            "type": "string",
                                            "const": "completed"
                                          },
                                          "settledAt": {
                                            "type": "number"
                                          },
                                          "result": {}
                                        },
                                        "required": [
                                          "id",
                                          "status",
                                          "settledAt",
                                          "result"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "pattern": "^t\\d+$"
                                          },
                                          "status": {
                                            "type": "string",
                                            "const": "failed"
                                          },
                                          "settledAt": {
                                            "type": "number"
                                          },
                                          "error": {}
                                        },
                                        "required": [
                                          "id",
                                          "status",
                                          "settledAt",
                                          "error"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "pattern": "^t\\d+$"
                                          },
                                          "status": {
                                            "type": "string",
                                            "const": "stopped"
                                          },
                                          "settledAt": {
                                            "type": "number"
                                          },
                                          "reason": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "id",
                                          "status",
                                          "settledAt",
                                          "reason"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "pattern": "^t\\d+$"
                                          },
                                          "status": {
                                            "type": "string",
                                            "const": "lost"
                                          },
                                          "settledAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "id",
                                          "status",
                                          "settledAt"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "settlement"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "heartbeat"
                                  },
                                  "timestamp": {
                                    "type": "number"
                                  },
                                  "activeTaskIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "timestamp",
                                  "activeTaskIds"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "todos"
                                  },
                                  "todos": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "content": {
                                          "type": "string"
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "pending",
                                            "in_progress",
                                            "completed",
                                            "failed"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "content",
                                        "status"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "todos"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "follow_up_queue"
                                  },
                                  "followUpQueue": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "message"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "followUpQueue"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "state_machine"
                                  },
                                  "stateMachine": {
                                    "type": "object",
                                    "properties": {
                                      "definition": {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "currentState": {
                                        "type": "string"
                                      },
                                      "currentInput": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "progress": {
                                        "type": "object",
                                        "properties": {
                                          "states": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "states"
                                        ],
                                        "additionalProperties": {}
                                      },
                                      "history": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      },
                                      "terminal": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "terminalAcknowledged": {
                                        "type": "boolean"
                                      },
                                      "createdAt": {
                                        "type": "number"
                                      },
                                      "updatedAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "definition",
                                      "prompt",
                                      "history",
                                      "createdAt",
                                      "updatedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "stateMachine"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "memory"
                                  },
                                  "phase": {
                                    "type": "string",
                                    "enum": [
                                      "observation",
                                      "reflection"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "completed"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "observations": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "usageBumpedObservations": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "phase",
                                  "status",
                                  "message"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "usage"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "turnUsage",
                                  "usageByModel",
                                  "lastMessageUsage",
                                  "effectiveContextWindow",
                                  "contextWindowUsage"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "system"
                                  },
                                  "level": {
                                    "type": "string",
                                    "enum": [
                                      "debug",
                                      "info",
                                      "warn",
                                      "error"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "providerRecovery": {
                                    "type": "object",
                                    "properties": {
                                      "fromModel": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 256
                                      },
                                      "fromRoute": {
                                        "type": "string",
                                        "enum": [
                                          "configured",
                                          "vercel",
                                          "unknown"
                                        ]
                                      },
                                      "toModel": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 256
                                      },
                                      "toRoute": {
                                        "type": "string",
                                        "const": "vercel"
                                      },
                                      "reason": {
                                        "type": "string",
                                        "enum": [
                                          "empty_response",
                                          "provider_error"
                                        ]
                                      },
                                      "status": {
                                        "type": "integer",
                                        "minimum": 100,
                                        "maximum": 599
                                      }
                                    },
                                    "required": [
                                      "fromModel",
                                      "fromRoute",
                                      "toModel",
                                      "toRoute",
                                      "reason"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "metadata": {
                                    "type": "object",
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "enum": [
                                          "storage_full",
                                          "session_cwd_fallback",
                                          "bound_agent_root_unavailable",
                                          "relay_backlog",
                                          "runner_exited",
                                          "relay_undeliverable",
                                          "interrupt_undeliverable"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "code"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "level",
                                  "message"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "router_switch"
                                  },
                                  "tier": {
                                    "type": "string"
                                  },
                                  "route": {
                                    "type": "string"
                                  },
                                  "fromModel": {
                                    "type": "string"
                                  },
                                  "toModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  },
                                  "trigger": {
                                    "type": "string",
                                    "enum": [
                                      "first_turn",
                                      "new_task",
                                      "idle",
                                      "manual_compact",
                                      "overflow",
                                      "modality_switch",
                                      "tier_change"
                                    ]
                                  },
                                  "rationale": {
                                    "type": "string"
                                  },
                                  "probabilities": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "number"
                                    }
                                  },
                                  "visionFallback": {
                                    "type": "boolean"
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "tier",
                                  "route",
                                  "fromModel",
                                  "toModel",
                                  "thinkingLevel",
                                  "trigger",
                                  "visionFallback"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "complete"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "result": {
                                    "type": "string"
                                  },
                                  "error": {
                                    "type": "string"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state",
                                  "status"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "ask"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state",
                                  "questions"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "interrupted"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "sleep"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "wakeAt": {
                                    "type": "number"
                                  },
                                  "pollWake": {
                                    "type": "boolean"
                                  },
                                  "quiet": {
                                    "type": "boolean",
                                    "const": true
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state",
                                  "wakeAt"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "turn_started"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "complete"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "result": {
                                    "type": "string"
                                  },
                                  "error": {
                                    "type": "string"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "ask"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "ask"
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "questions"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "interrupted"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "interrupted"
                                  },
                                  "error": {
                                    "type": "string"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "sleep"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "sleep"
                                  },
                                  "wakeAt": {
                                    "type": "number"
                                  },
                                  "pollWake": {
                                    "type": "boolean"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "wakeAt"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "session_created"
                              },
                              "prompt": {
                                "type": "string"
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "clientRequestId": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                              }
                            },
                            "required": [
                              "type",
                              "prompt",
                              "createdAt"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "interrupt_requested"
                              },
                              "requestedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "requestedAt"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "agent_message"
                              },
                              "message": {
                                "type": "string",
                                "minLength": 1
                              },
                              "createdAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "message",
                              "createdAt"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "view_shown"
                              },
                              "view": {
                                "type": "string"
                              },
                              "createdAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "view",
                              "createdAt"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "prompt_submitted"
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "inputKind": {
                                    "type": "string",
                                    "enum": [
                                      "initial",
                                      "message"
                                    ]
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "sender": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "user"
                                          },
                                          "userId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "userId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "app"
                                          },
                                          "appId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "appId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "session"
                                          },
                                          "sessionId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "sessionId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "system"
                                          }
                                        },
                                        "required": [
                                          "kind"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "clientRequestId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                  },
                                  "images": {
                                    "maxItems": 4,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "storageId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "enum": [
                                            "image/png",
                                            "image/jpeg",
                                            "image/webp",
                                            "image/gif"
                                          ]
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 5242880
                                        }
                                      },
                                      "required": [
                                        "storageId",
                                        "mimeType",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "attachments": {
                                    "maxItems": 10,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "path": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "name": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 255
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 9007199254740991
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "required": [
                                        "path",
                                        "name",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "dictated": {
                                    "type": "boolean",
                                    "const": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "prompt",
                                  "inputKind",
                                  "behavior",
                                  "sender"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "note_submitted"
                                  },
                                  "note": {
                                    "type": "string"
                                  },
                                  "sender": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "user"
                                          },
                                          "userId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "userId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "app"
                                          },
                                          "appId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "appId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "session"
                                          },
                                          "sessionId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "sessionId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "system"
                                          }
                                        },
                                        "required": [
                                          "kind"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "clientRequestId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                  },
                                  "images": {
                                    "maxItems": 4,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "storageId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "enum": [
                                            "image/png",
                                            "image/jpeg",
                                            "image/webp",
                                            "image/gif"
                                          ]
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 5242880
                                        }
                                      },
                                      "required": [
                                        "storageId",
                                        "mimeType",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "attachments": {
                                    "maxItems": 10,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "path": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "name": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 255
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 9007199254740991
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "required": [
                                        "path",
                                        "name",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "dictated": {
                                    "type": "boolean",
                                    "const": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "note",
                                  "sender"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "answer_submitted"
                                  },
                                  "answer": {
                                    "type": "string"
                                  },
                                  "sender": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "user"
                                          },
                                          "userId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "userId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "app"
                                          },
                                          "appId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "appId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "session"
                                          },
                                          "sessionId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "sessionId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "system"
                                          }
                                        },
                                        "required": [
                                          "kind"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "clientRequestId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                  },
                                  "images": {
                                    "maxItems": 4,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "storageId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "enum": [
                                            "image/png",
                                            "image/jpeg",
                                            "image/webp",
                                            "image/gif"
                                          ]
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 5242880
                                        }
                                      },
                                      "required": [
                                        "storageId",
                                        "mimeType",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "attachments": {
                                    "maxItems": 10,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "path": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "name": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 255
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 9007199254740991
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "required": [
                                        "path",
                                        "name",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "dictated": {
                                    "type": "boolean",
                                    "const": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "answer",
                                  "sender"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": {}
                      }
                    ]
                  },
                  "createdAt": {
                    "type": "number"
                  }
                },
                "required": [
                  "seq",
                  "event",
                  "createdAt"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "events"
          ],
          "additionalProperties": false
        },
        "dispatched": {
          "type": "boolean",
          "const": false
        },
        "delivery": {
          "type": "string",
          "enum": [
            "accepted",
            "queued"
          ]
        }
      },
      "required": [
        "url",
        "session",
        "snapshot",
        "history",
        "dispatched",
        "delivery"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "sessionId"
      ],
      "additionalProperties": false
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/sessions/wait

Create a session and wait for the submitted turn to finish

CLI
bento session create --agent seo-specialist --title "heybento.ai" --prompt "..."
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "prompt": {
      "type": "string",
      "description": "The words of the input. May be empty when it carries images or attachments."
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "clientRequestId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "agent": {
      "description": "The agent that owns the session, by slug; `root` is the workspace agent. The session runs in the agent's folder. Not with cwd.",
      "type": "string"
    },
    "cwd": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024,
      "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
    },
    "images": {
      "maxItems": 4,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "minLength": 1
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp",
              "image/gif"
            ]
          }
        },
        "required": [
          "data",
          "mimeType"
        ]
      }
    },
    "attachments": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "mimeType": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "path",
          "name",
          "bytes"
        ]
      }
    },
    "dictated": {
      "description": "True when the words were transcribed from speech.",
      "type": "boolean"
    },
    "tier": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "behavior": {
      "default": "steer",
      "type": "string",
      "enum": [
        "steer",
        "follow_up"
      ]
    },
    "mode": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "prompt": {
          "type": "string"
        },
        "states": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        }
      },
      "required": [
        "name",
        "prompt",
        "states"
      ]
    },
    "audience": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "specific"
        },
        "memberUserIds": {
          "maxItems": 100,
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "kind",
        "memberUserIds"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "prompt",
    "clientRequestId"
  ],
  "additionalProperties": false
}
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "waitMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 720000
    }
  }
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "cwd": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
        },
        "terminal": {
          "type": "object",
          "properties": {
            "seq": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "event": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "step"
                            },
                            "step": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call_start"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "isError": {
                                      "type": "boolean"
                                    },
                                    "output": {
                                      "type": "array",
                                      "items": {
                                        "oneOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "text"
                                              },
                                              "text": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "text"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "image"
                                              },
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "details": {}
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId",
                                    "isError"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "system"
                                    },
                                    "message": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "step"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_started"
                            },
                            "task": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "tool",
                                    "subagent",
                                    "scheduled"
                                  ]
                                },
                                "name": {
                                  "type": "string"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "ownerScopeId": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "pattern": "^turn-\\d+$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^task:t\\d+$"
                                    }
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "scheduled",
                                    "completed",
                                    "failed",
                                    "stopped",
                                    "lost"
                                  ]
                                },
                                "startedAt": {
                                  "type": "number"
                                },
                                "wakeAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "id",
                                "kind",
                                "name",
                                "label",
                                "ownerScopeId",
                                "status",
                                "startedAt"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "task"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_output"
                            },
                            "taskId": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "chunk": {
                              "type": "string"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "taskId",
                            "chunk"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_settled"
                            },
                            "settlement": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "completed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "result": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "result"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "failed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "error": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "error"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "stopped"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "reason": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "reason"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "lost"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "settlement"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "heartbeat"
                            },
                            "timestamp": {
                              "type": "number"
                            },
                            "activeTaskIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            }
                          },
                          "required": [
                            "type",
                            "timestamp",
                            "activeTaskIds"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "todos"
                            },
                            "todos": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "in_progress",
                                      "completed",
                                      "failed"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "content",
                                  "status"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "todos"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "follow_up_queue"
                            },
                            "followUpQueue": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "message"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "followUpQueue"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "state_machine"
                            },
                            "stateMachine": {
                              "type": "object",
                              "properties": {
                                "definition": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "states": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "prompt",
                                    "states"
                                  ],
                                  "additionalProperties": false
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "currentState": {
                                  "type": "string"
                                },
                                "currentInput": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "progress": {
                                  "type": "object",
                                  "properties": {
                                    "states": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "states"
                                  ],
                                  "additionalProperties": {}
                                },
                                "history": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "terminal": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "terminalAcknowledged": {
                                  "type": "boolean"
                                },
                                "createdAt": {
                                  "type": "number"
                                },
                                "updatedAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "definition",
                                "prompt",
                                "history",
                                "createdAt",
                                "updatedAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "stateMachine"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "memory"
                            },
                            "phase": {
                              "type": "string",
                              "enum": [
                                "observation",
                                "reflection"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "completed"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "observations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "usageBumpedObservations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "type",
                            "phase",
                            "status",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "usage"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "turnUsage",
                            "usageByModel",
                            "lastMessageUsage",
                            "effectiveContextWindow",
                            "contextWindowUsage"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "system"
                            },
                            "level": {
                              "type": "string",
                              "enum": [
                                "debug",
                                "info",
                                "warn",
                                "error"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "providerRecovery": {
                              "type": "object",
                              "properties": {
                                "fromModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "fromRoute": {
                                  "type": "string",
                                  "enum": [
                                    "configured",
                                    "vercel",
                                    "unknown"
                                  ]
                                },
                                "toModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "toRoute": {
                                  "type": "string",
                                  "const": "vercel"
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "empty_response",
                                    "provider_error"
                                  ]
                                },
                                "status": {
                                  "type": "integer",
                                  "minimum": 100,
                                  "maximum": 599
                                }
                              },
                              "required": [
                                "fromModel",
                                "fromRoute",
                                "toModel",
                                "toRoute",
                                "reason"
                              ],
                              "additionalProperties": false
                            },
                            "metadata": {
                              "type": "object",
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "enum": [
                                    "storage_full",
                                    "session_cwd_fallback",
                                    "bound_agent_root_unavailable",
                                    "relay_backlog",
                                    "runner_exited",
                                    "relay_undeliverable",
                                    "interrupt_undeliverable"
                                  ]
                                }
                              },
                              "required": [
                                "code"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "level",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "router_switch"
                            },
                            "tier": {
                              "type": "string"
                            },
                            "route": {
                              "type": "string"
                            },
                            "fromModel": {
                              "type": "string"
                            },
                            "toModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            },
                            "trigger": {
                              "type": "string",
                              "enum": [
                                "first_turn",
                                "new_task",
                                "idle",
                                "manual_compact",
                                "overflow",
                                "modality_switch",
                                "tier_change"
                              ]
                            },
                            "rationale": {
                              "type": "string"
                            },
                            "probabilities": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "visionFallback": {
                              "type": "boolean"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "tier",
                            "route",
                            "fromModel",
                            "toModel",
                            "thinkingLevel",
                            "trigger",
                            "visionFallback"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "status"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "quiet": {
                              "type": "boolean",
                              "const": true
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "status": {
                              "type": "string",
                              "const": "ask"
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "status": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "status": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "session_created"
                        },
                        "prompt": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "clientRequestId": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "required": [
                        "type",
                        "prompt",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "interrupt_requested"
                        },
                        "requestedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "requestedAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "agent_message"
                        },
                        "message": {
                          "type": "string",
                          "minLength": 1
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "view_shown"
                        },
                        "view": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "view",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "prompt_submitted"
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "inputKind": {
                              "type": "string",
                              "enum": [
                                "initial",
                                "message"
                              ]
                            },
                            "behavior": {
                              "type": "string",
                              "enum": [
                                "steer",
                                "follow_up"
                              ]
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "prompt",
                            "inputKind",
                            "behavior",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "note_submitted"
                            },
                            "note": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "note",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "answer_submitted"
                            },
                            "answer": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "answer",
                            "sender"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    }
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": {}
                }
              ]
            },
            "createdAt": {
              "type": "number"
            }
          },
          "required": [
            "seq",
            "event",
            "createdAt"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "sessionId",
        "inputSeq",
        "url",
        "terminal"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "status": {
          "type": "string",
          "const": "running"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [
        "sessionId",
        "inputSeq",
        "status",
        "url"
      ],
      "additionalProperties": false
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/children

Create a child session inheriting its parent context

CLI
bento session child create --session-id example --prompt "..." --agent seo-specialist
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "prompt": {
      "type": "string",
      "description": "The words of the input. May be empty when it carries images or attachments."
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "clientRequestId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "agent": {
      "description": "The agent that owns the session, by slug; `root` is the workspace agent. The session runs in the agent's folder. Not with cwd.",
      "type": "string"
    },
    "cwd": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024,
      "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
    },
    "images": {
      "maxItems": 4,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "minLength": 1
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp",
              "image/gif"
            ]
          }
        },
        "required": [
          "data",
          "mimeType"
        ]
      }
    },
    "attachments": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "mimeType": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "path",
          "name",
          "bytes"
        ]
      }
    },
    "dictated": {
      "description": "True when the words were transcribed from speech.",
      "type": "boolean"
    },
    "tier": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "behavior": {
      "default": "steer",
      "type": "string",
      "enum": [
        "steer",
        "follow_up"
      ]
    },
    "mode": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "prompt": {
          "type": "string"
        },
        "states": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        }
      },
      "required": [
        "name",
        "prompt",
        "states"
      ]
    }
  },
  "required": [
    "prompt"
  ],
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "format": "uri"
    },
    "session": {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "running",
            "complete",
            "ask",
            "interrupted",
            "sleep"
          ]
        },
        "lastEventSeq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "lastDeliveredInputSeq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "sessionId",
        "status",
        "lastEventSeq",
        "lastDeliveredInputSeq"
      ],
      "additionalProperties": false
    },
    "snapshot": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "pinned": {
          "type": "boolean"
        },
        "pin": {
          "type": "object",
          "properties": {
            "pinned": {
              "type": "boolean"
            },
            "version": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "pinned",
            "version"
          ],
          "additionalProperties": false
        },
        "turnStatus": {
          "type": "string",
          "enum": [
            "running",
            "complete",
            "ask",
            "interrupted",
            "sleep"
          ]
        },
        "turnError": {
          "type": "string"
        },
        "bucket": {
          "type": "string",
          "enum": [
            "asking",
            "running",
            "scheduled",
            "done"
          ]
        },
        "title": {
          "type": "string"
        },
        "titleOrigin": {
          "type": "string",
          "enum": [
            "excerpt",
            "auto",
            "manual"
          ]
        },
        "titleStatus": {
          "type": "string",
          "enum": [
            "generating",
            "complete",
            "failed"
          ]
        },
        "cwd": {
          "type": "string"
        },
        "agent": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "slug": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": false
        },
        "onboarding": {
          "type": "boolean"
        },
        "createdBySessionId": {
          "type": "string"
        },
        "machine": {
          "type": "object",
          "properties": {
            "definitionName": {
              "type": "string"
            },
            "currentState": {
              "type": "string"
            },
            "followingDefinitionState": {
              "type": "string"
            },
            "progress": {
              "type": "object",
              "properties": {
                "completed": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "total": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "completed",
                "total"
              ],
              "additionalProperties": false
            },
            "orderedPath": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "index": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "name": {
                    "type": "string"
                  },
                  "kind": {
                    "type": "string"
                  },
                  "phase": {
                    "type": "string",
                    "enum": [
                      "past",
                      "current",
                      "future",
                      "outcome"
                    ]
                  },
                  "terminalStatus": {
                    "type": "string",
                    "enum": [
                      "completed",
                      "failed",
                      "cancelled",
                      "error"
                    ]
                  }
                },
                "required": [
                  "key",
                  "index",
                  "name",
                  "phase"
                ],
                "additionalProperties": false
              }
            },
            "activity": {
              "type": "string",
              "enum": [
                "running",
                "sleeping",
                "waiting",
                "idle"
              ]
            },
            "nextWakeAt": {
              "type": "number"
            },
            "pollIntervalMs": {
              "type": "number"
            },
            "outcome": {
              "type": "string",
              "enum": [
                "interrupted",
                "completed",
                "failed",
                "cancelled",
                "error"
              ]
            }
          },
          "required": [
            "orderedPath",
            "activity"
          ],
          "additionalProperties": false
        },
        "createdAt": {
          "type": "number"
        },
        "updatedAt": {
          "type": "number"
        },
        "lastEventSeq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "unread": {
          "type": "boolean"
        },
        "audience": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "workspace"
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "specific"
                },
                "count": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "preview": {
                  "maxItems": 5,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "memberId": {
                        "type": "string"
                      },
                      "userId": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      "role": {
                        "type": "string",
                        "enum": [
                          "owner",
                          "editor",
                          "viewer"
                        ]
                      }
                    },
                    "required": [
                      "memberId",
                      "userId",
                      "name",
                      "email",
                      "role"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "kind",
                "count",
                "preview"
              ],
              "additionalProperties": false
            }
          ]
        },
        "archive": {
          "type": "object",
          "properties": {
            "globalArchivedAt": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "globalArchiveOrigin": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "manual",
                    "automatic"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "personalArchivedAt": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "reason": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "global",
                    "personal"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "globalArchivedAt",
            "globalArchiveOrigin",
            "personalArchivedAt",
            "reason"
          ],
          "additionalProperties": false
        },
        "permissions": {
          "type": "object",
          "properties": {
            "send": {
              "type": "boolean"
            },
            "answer": {
              "type": "boolean"
            },
            "interrupt": {
              "type": "boolean"
            },
            "rename": {
              "type": "boolean"
            },
            "pin": {
              "type": "boolean"
            },
            "manageAudience": {
              "type": "boolean"
            },
            "personalArchive": {
              "type": "boolean"
            },
            "globalArchive": {
              "type": "boolean"
            },
            "delete": {
              "type": "boolean"
            }
          },
          "required": [
            "send",
            "answer",
            "interrupt",
            "rename",
            "pin",
            "manageAudience",
            "personalArchive",
            "globalArchive",
            "delete"
          ],
          "additionalProperties": false
        },
        "view": {
          "type": "string"
        },
        "viewRevision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "viewBy": {
          "type": "string",
          "enum": [
            "user",
            "agent"
          ]
        },
        "workspaceId": {
          "type": "string"
        },
        "tier": {
          "type": "string",
          "enum": [
            "frontier",
            "balanced",
            "economy",
            "openai-frontier",
            "openai-max",
            "anthropic-frontier",
            "anthropic-max",
            "anthropic-balanced",
            "google-recommended",
            "google-balanced"
          ]
        },
        "lastDeliveredInputSeq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "deliveryAttempt": {
          "type": "object",
          "properties": {
            "attemptId": {
              "type": "string",
              "minLength": 1
            },
            "throughSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "kind": {
              "type": "string",
              "enum": [
                "initial_prompt",
                "message",
                "answer"
              ]
            },
            "createdAt": {
              "type": "number"
            }
          },
          "required": [
            "attemptId",
            "throughSeq",
            "kind",
            "createdAt"
          ],
          "additionalProperties": false
        },
        "todos": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "content": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "in_progress",
                  "completed",
                  "failed"
                ]
              }
            },
            "required": [
              "id",
              "content",
              "status"
            ],
            "additionalProperties": false
          }
        },
        "followUpQueue": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "images": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "string"
                    },
                    "mimeType": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "data",
                    "mimeType"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "message"
            ],
            "additionalProperties": false
          }
        },
        "requestedMachine": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "prompt": {
              "type": "string"
            },
            "states": {
              "type": "array",
              "items": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              }
            }
          },
          "required": [
            "name",
            "prompt",
            "states"
          ],
          "additionalProperties": false
        },
        "machineState": {
          "type": "object",
          "properties": {
            "definition": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "prompt": {
                  "type": "string"
                },
                "states": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                }
              },
              "required": [
                "name",
                "prompt",
                "states"
              ],
              "additionalProperties": false
            },
            "prompt": {
              "type": "string"
            },
            "currentState": {
              "type": "string"
            },
            "currentInput": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {}
            },
            "progress": {
              "type": "object",
              "properties": {
                "states": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                }
              },
              "required": [
                "states"
              ],
              "additionalProperties": {}
            },
            "history": {
              "type": "array",
              "items": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              }
            },
            "terminal": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {}
            },
            "terminalAcknowledged": {
              "type": "boolean"
            },
            "createdAt": {
              "type": "number"
            },
            "updatedAt": {
              "type": "number"
            }
          },
          "required": [
            "definition",
            "prompt",
            "history",
            "createdAt",
            "updatedAt"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "id",
        "pinned",
        "turnStatus",
        "bucket",
        "title",
        "titleOrigin",
        "titleStatus",
        "createdAt",
        "updatedAt",
        "lastEventSeq",
        "unread",
        "audience",
        "archive",
        "permissions",
        "workspaceId",
        "lastDeliveredInputSeq"
      ],
      "additionalProperties": false
    },
    "history": {
      "type": "object",
      "properties": {
        "events": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "seq": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "event": {
                "anyOf": [
                  {
                    "anyOf": [
                      {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "turn_started"
                              },
                              "state": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting_for_human",
                                      "sleeping",
                                      "interrupted",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "mode": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "const": "agent"
                                      },
                                      {
                                        "type": "string",
                                        "const": "auto"
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "options": {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "type": "string"
                                      },
                                      "memoryModel": {
                                        "type": "string"
                                      },
                                      "thinkingLevel": {
                                        "type": "string",
                                        "enum": [
                                          "minimal",
                                          "low",
                                          "medium",
                                          "high",
                                          "xhigh"
                                        ]
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "agent": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "messages": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "role": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "role"
                                          ],
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "messages"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "stateMachine": {
                                    "type": "object",
                                    "properties": {
                                      "definition": {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "currentState": {
                                        "type": "string"
                                      },
                                      "currentInput": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "progress": {
                                        "type": "object",
                                        "properties": {
                                          "states": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "states"
                                        ],
                                        "additionalProperties": {}
                                      },
                                      "history": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      },
                                      "terminal": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "terminalAcknowledged": {
                                        "type": "boolean"
                                      },
                                      "createdAt": {
                                        "type": "number"
                                      },
                                      "updatedAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "definition",
                                      "prompt",
                                      "history",
                                      "createdAt",
                                      "updatedAt"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "pendingStateTransition": {
                                    "type": "object",
                                    "properties": {
                                      "stateName": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "stateName"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "todos": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "content": {
                                          "type": "string"
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "pending",
                                            "in_progress",
                                            "completed",
                                            "failed"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "content",
                                        "status"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "followUpQueue": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "message"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "queuedCommands": {
                                    "type": "array",
                                    "items": {
                                      "oneOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "prompt"
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "message",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "answer"
                                            },
                                            "questions": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "question": {
                                                    "type": "string"
                                                  },
                                                  "header": {
                                                    "type": "string"
                                                  },
                                                  "options": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "object",
                                                      "properties": {
                                                        "label": {
                                                          "type": "string"
                                                        },
                                                        "description": {
                                                          "type": "string"
                                                        }
                                                      },
                                                      "required": [
                                                        "label"
                                                      ],
                                                      "additionalProperties": false
                                                    }
                                                  },
                                                  "multiSelect": {
                                                    "type": "boolean"
                                                  }
                                                },
                                                "required": [
                                                  "question",
                                                  "options"
                                                ],
                                                "additionalProperties": false
                                              }
                                            },
                                            "answers": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              }
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "questions",
                                            "answers",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "wake"
                                            }
                                          },
                                          "required": [
                                            "type"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "tasks": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "kind": {
                                          "type": "string",
                                          "enum": [
                                            "tool",
                                            "subagent",
                                            "scheduled"
                                          ]
                                        },
                                        "name": {
                                          "type": "string"
                                        },
                                        "label": {
                                          "type": "string"
                                        },
                                        "ownerScopeId": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "pattern": "^turn-\\d+$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^task:t\\d+$"
                                            }
                                          ]
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "running",
                                            "scheduled",
                                            "completed",
                                            "failed",
                                            "stopped",
                                            "lost"
                                          ]
                                        },
                                        "startedAt": {
                                          "type": "number"
                                        },
                                        "wakeAt": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "kind",
                                        "name",
                                        "label",
                                        "ownerScopeId",
                                        "status",
                                        "startedAt"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "taskOutputTails": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "pendingLostTaskReminderTaskIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    }
                                  },
                                  "nextTaskId": {
                                    "type": "number"
                                  },
                                  "wireGuardHorizon": {
                                    "type": "object",
                                    "properties": {
                                      "evictionHorizon": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "evictionHorizon"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "routing": {
                                    "type": "object",
                                    "properties": {
                                      "saved": {
                                        "type": "object",
                                        "properties": {
                                          "tier": {
                                            "type": "string"
                                          },
                                          "route": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "tier",
                                          "route"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "compactedSinceLastMessage": {
                                        "type": "boolean"
                                      },
                                      "currentTask": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "status",
                                  "mode",
                                  "agent"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "state"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "step"
                              },
                              "step": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "text_delta"
                                      },
                                      "delta": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "delta"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "reasoning_delta"
                                      },
                                      "delta": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "delta"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "text"
                                      },
                                      "text": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "text"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "reasoning"
                                      },
                                      "text": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "text"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "tool_call_start"
                                      },
                                      "toolName": {
                                        "type": "string"
                                      },
                                      "toolCallId": {
                                        "type": "string"
                                      },
                                      "input": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "toolName",
                                      "toolCallId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "tool_call"
                                      },
                                      "toolName": {
                                        "type": "string"
                                      },
                                      "toolCallId": {
                                        "type": "string"
                                      },
                                      "input": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "isError": {
                                        "type": "boolean"
                                      },
                                      "output": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "text"
                                                },
                                                "text": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "text"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "image"
                                                },
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "details": {}
                                    },
                                    "required": [
                                      "type",
                                      "toolName",
                                      "toolCallId",
                                      "isError"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "system"
                                      },
                                      "message": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "origin": {
                                "type": "object",
                                "properties": {
                                  "taskId": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "required": [
                                  "taskId"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "step"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "task_started"
                              },
                              "task": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "kind": {
                                    "type": "string",
                                    "enum": [
                                      "tool",
                                      "subagent",
                                      "scheduled"
                                    ]
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "label": {
                                    "type": "string"
                                  },
                                  "ownerScopeId": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "pattern": "^turn-\\d+$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^task:t\\d+$"
                                      }
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "scheduled",
                                      "completed",
                                      "failed",
                                      "stopped",
                                      "lost"
                                    ]
                                  },
                                  "startedAt": {
                                    "type": "number"
                                  },
                                  "wakeAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "id",
                                  "kind",
                                  "name",
                                  "label",
                                  "ownerScopeId",
                                  "status",
                                  "startedAt"
                                ],
                                "additionalProperties": false
                              },
                              "origin": {
                                "type": "object",
                                "properties": {
                                  "taskId": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "required": [
                                  "taskId"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "task"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "task_output"
                              },
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              },
                              "chunk": {
                                "type": "string"
                              },
                              "origin": {
                                "type": "object",
                                "properties": {
                                  "taskId": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "required": [
                                  "taskId"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "taskId",
                              "chunk"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "task_settled"
                              },
                              "settlement": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "status": {
                                        "type": "string",
                                        "const": "completed"
                                      },
                                      "settledAt": {
                                        "type": "number"
                                      },
                                      "result": {}
                                    },
                                    "required": [
                                      "id",
                                      "status",
                                      "settledAt",
                                      "result"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "status": {
                                        "type": "string",
                                        "const": "failed"
                                      },
                                      "settledAt": {
                                        "type": "number"
                                      },
                                      "error": {}
                                    },
                                    "required": [
                                      "id",
                                      "status",
                                      "settledAt",
                                      "error"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "status": {
                                        "type": "string",
                                        "const": "stopped"
                                      },
                                      "settledAt": {
                                        "type": "number"
                                      },
                                      "reason": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "status",
                                      "settledAt",
                                      "reason"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "status": {
                                        "type": "string",
                                        "const": "lost"
                                      },
                                      "settledAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "status",
                                      "settledAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "origin": {
                                "type": "object",
                                "properties": {
                                  "taskId": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "required": [
                                  "taskId"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "settlement"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "heartbeat"
                              },
                              "timestamp": {
                                "type": "number"
                              },
                              "activeTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              }
                            },
                            "required": [
                              "type",
                              "timestamp",
                              "activeTaskIds"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "todos"
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "type",
                              "todos"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "follow_up_queue"
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "type",
                              "followUpQueue"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "state_machine"
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "stateMachine"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "memory"
                              },
                              "phase": {
                                "type": "string",
                                "enum": [
                                  "observation",
                                  "reflection"
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "completed"
                                ]
                              },
                              "message": {
                                "type": "string"
                              },
                              "observations": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                }
                              },
                              "usageBumpedObservations": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                }
                              }
                            },
                            "required": [
                              "type",
                              "phase",
                              "status",
                              "message"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "usage"
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              },
                              "origin": {
                                "type": "object",
                                "properties": {
                                  "taskId": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "required": [
                                  "taskId"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "turnUsage",
                              "usageByModel",
                              "lastMessageUsage",
                              "effectiveContextWindow",
                              "contextWindowUsage"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "system"
                              },
                              "level": {
                                "type": "string",
                                "enum": [
                                  "debug",
                                  "info",
                                  "warn",
                                  "error"
                                ]
                              },
                              "message": {
                                "type": "string"
                              },
                              "providerRecovery": {
                                "type": "object",
                                "properties": {
                                  "fromModel": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 256
                                  },
                                  "fromRoute": {
                                    "type": "string",
                                    "enum": [
                                      "configured",
                                      "vercel",
                                      "unknown"
                                    ]
                                  },
                                  "toModel": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 256
                                  },
                                  "toRoute": {
                                    "type": "string",
                                    "const": "vercel"
                                  },
                                  "reason": {
                                    "type": "string",
                                    "enum": [
                                      "empty_response",
                                      "provider_error"
                                    ]
                                  },
                                  "status": {
                                    "type": "integer",
                                    "minimum": 100,
                                    "maximum": 599
                                  }
                                },
                                "required": [
                                  "fromModel",
                                  "fromRoute",
                                  "toModel",
                                  "toRoute",
                                  "reason"
                                ],
                                "additionalProperties": false
                              },
                              "metadata": {
                                "type": "object",
                                "properties": {
                                  "code": {
                                    "type": "string",
                                    "enum": [
                                      "storage_full",
                                      "session_cwd_fallback",
                                      "bound_agent_root_unavailable",
                                      "relay_backlog",
                                      "runner_exited",
                                      "relay_undeliverable",
                                      "interrupt_undeliverable"
                                    ]
                                  }
                                },
                                "required": [
                                  "code"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "level",
                              "message"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "router_switch"
                              },
                              "tier": {
                                "type": "string"
                              },
                              "route": {
                                "type": "string"
                              },
                              "fromModel": {
                                "type": "string"
                              },
                              "toModel": {
                                "type": "string"
                              },
                              "thinkingLevel": {
                                "type": "string",
                                "enum": [
                                  "minimal",
                                  "low",
                                  "medium",
                                  "high",
                                  "xhigh"
                                ]
                              },
                              "trigger": {
                                "type": "string",
                                "enum": [
                                  "first_turn",
                                  "new_task",
                                  "idle",
                                  "manual_compact",
                                  "overflow",
                                  "modality_switch",
                                  "tier_change"
                                ]
                              },
                              "rationale": {
                                "type": "string"
                              },
                              "probabilities": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {
                                  "type": "number"
                                }
                              },
                              "visionFallback": {
                                "type": "boolean"
                              },
                              "origin": {
                                "type": "object",
                                "properties": {
                                  "taskId": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "required": [
                                  "taskId"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "tier",
                              "route",
                              "fromModel",
                              "toModel",
                              "thinkingLevel",
                              "trigger",
                              "visionFallback"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "complete"
                              },
                              "state": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting_for_human",
                                      "sleeping",
                                      "interrupted",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "mode": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "const": "agent"
                                      },
                                      {
                                        "type": "string",
                                        "const": "auto"
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "options": {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "type": "string"
                                      },
                                      "memoryModel": {
                                        "type": "string"
                                      },
                                      "thinkingLevel": {
                                        "type": "string",
                                        "enum": [
                                          "minimal",
                                          "low",
                                          "medium",
                                          "high",
                                          "xhigh"
                                        ]
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "agent": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "messages": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "role": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "role"
                                          ],
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "messages"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "stateMachine": {
                                    "type": "object",
                                    "properties": {
                                      "definition": {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "currentState": {
                                        "type": "string"
                                      },
                                      "currentInput": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "progress": {
                                        "type": "object",
                                        "properties": {
                                          "states": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "states"
                                        ],
                                        "additionalProperties": {}
                                      },
                                      "history": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      },
                                      "terminal": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "terminalAcknowledged": {
                                        "type": "boolean"
                                      },
                                      "createdAt": {
                                        "type": "number"
                                      },
                                      "updatedAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "definition",
                                      "prompt",
                                      "history",
                                      "createdAt",
                                      "updatedAt"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "pendingStateTransition": {
                                    "type": "object",
                                    "properties": {
                                      "stateName": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "stateName"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "todos": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "content": {
                                          "type": "string"
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "pending",
                                            "in_progress",
                                            "completed",
                                            "failed"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "content",
                                        "status"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "followUpQueue": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "message"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "queuedCommands": {
                                    "type": "array",
                                    "items": {
                                      "oneOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "prompt"
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "message",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "answer"
                                            },
                                            "questions": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "question": {
                                                    "type": "string"
                                                  },
                                                  "header": {
                                                    "type": "string"
                                                  },
                                                  "options": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "object",
                                                      "properties": {
                                                        "label": {
                                                          "type": "string"
                                                        },
                                                        "description": {
                                                          "type": "string"
                                                        }
                                                      },
                                                      "required": [
                                                        "label"
                                                      ],
                                                      "additionalProperties": false
                                                    }
                                                  },
                                                  "multiSelect": {
                                                    "type": "boolean"
                                                  }
                                                },
                                                "required": [
                                                  "question",
                                                  "options"
                                                ],
                                                "additionalProperties": false
                                              }
                                            },
                                            "answers": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              }
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "questions",
                                            "answers",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "wake"
                                            }
                                          },
                                          "required": [
                                            "type"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "tasks": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "kind": {
                                          "type": "string",
                                          "enum": [
                                            "tool",
                                            "subagent",
                                            "scheduled"
                                          ]
                                        },
                                        "name": {
                                          "type": "string"
                                        },
                                        "label": {
                                          "type": "string"
                                        },
                                        "ownerScopeId": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "pattern": "^turn-\\d+$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^task:t\\d+$"
                                            }
                                          ]
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "running",
                                            "scheduled",
                                            "completed",
                                            "failed",
                                            "stopped",
                                            "lost"
                                          ]
                                        },
                                        "startedAt": {
                                          "type": "number"
                                        },
                                        "wakeAt": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "kind",
                                        "name",
                                        "label",
                                        "ownerScopeId",
                                        "status",
                                        "startedAt"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "taskOutputTails": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "pendingLostTaskReminderTaskIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    }
                                  },
                                  "nextTaskId": {
                                    "type": "number"
                                  },
                                  "wireGuardHorizon": {
                                    "type": "object",
                                    "properties": {
                                      "evictionHorizon": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "evictionHorizon"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "routing": {
                                    "type": "object",
                                    "properties": {
                                      "saved": {
                                        "type": "object",
                                        "properties": {
                                          "tier": {
                                            "type": "string"
                                          },
                                          "route": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "tier",
                                          "route"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "compactedSinceLastMessage": {
                                        "type": "boolean"
                                      },
                                      "currentTask": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "status",
                                  "mode",
                                  "agent"
                                ],
                                "additionalProperties": false
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "result": {
                                "type": "string"
                              },
                              "error": {
                                "type": "string"
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "state",
                              "status"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "ask"
                              },
                              "state": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting_for_human",
                                      "sleeping",
                                      "interrupted",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "mode": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "const": "agent"
                                      },
                                      {
                                        "type": "string",
                                        "const": "auto"
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "options": {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "type": "string"
                                      },
                                      "memoryModel": {
                                        "type": "string"
                                      },
                                      "thinkingLevel": {
                                        "type": "string",
                                        "enum": [
                                          "minimal",
                                          "low",
                                          "medium",
                                          "high",
                                          "xhigh"
                                        ]
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "agent": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "messages": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "role": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "role"
                                          ],
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "messages"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "stateMachine": {
                                    "type": "object",
                                    "properties": {
                                      "definition": {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "currentState": {
                                        "type": "string"
                                      },
                                      "currentInput": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "progress": {
                                        "type": "object",
                                        "properties": {
                                          "states": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "states"
                                        ],
                                        "additionalProperties": {}
                                      },
                                      "history": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      },
                                      "terminal": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "terminalAcknowledged": {
                                        "type": "boolean"
                                      },
                                      "createdAt": {
                                        "type": "number"
                                      },
                                      "updatedAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "definition",
                                      "prompt",
                                      "history",
                                      "createdAt",
                                      "updatedAt"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "pendingStateTransition": {
                                    "type": "object",
                                    "properties": {
                                      "stateName": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "stateName"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "todos": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "content": {
                                          "type": "string"
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "pending",
                                            "in_progress",
                                            "completed",
                                            "failed"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "content",
                                        "status"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "followUpQueue": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "message"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "queuedCommands": {
                                    "type": "array",
                                    "items": {
                                      "oneOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "prompt"
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "message",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "answer"
                                            },
                                            "questions": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "question": {
                                                    "type": "string"
                                                  },
                                                  "header": {
                                                    "type": "string"
                                                  },
                                                  "options": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "object",
                                                      "properties": {
                                                        "label": {
                                                          "type": "string"
                                                        },
                                                        "description": {
                                                          "type": "string"
                                                        }
                                                      },
                                                      "required": [
                                                        "label"
                                                      ],
                                                      "additionalProperties": false
                                                    }
                                                  },
                                                  "multiSelect": {
                                                    "type": "boolean"
                                                  }
                                                },
                                                "required": [
                                                  "question",
                                                  "options"
                                                ],
                                                "additionalProperties": false
                                              }
                                            },
                                            "answers": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              }
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "questions",
                                            "answers",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "wake"
                                            }
                                          },
                                          "required": [
                                            "type"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "tasks": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "kind": {
                                          "type": "string",
                                          "enum": [
                                            "tool",
                                            "subagent",
                                            "scheduled"
                                          ]
                                        },
                                        "name": {
                                          "type": "string"
                                        },
                                        "label": {
                                          "type": "string"
                                        },
                                        "ownerScopeId": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "pattern": "^turn-\\d+$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^task:t\\d+$"
                                            }
                                          ]
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "running",
                                            "scheduled",
                                            "completed",
                                            "failed",
                                            "stopped",
                                            "lost"
                                          ]
                                        },
                                        "startedAt": {
                                          "type": "number"
                                        },
                                        "wakeAt": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "kind",
                                        "name",
                                        "label",
                                        "ownerScopeId",
                                        "status",
                                        "startedAt"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "taskOutputTails": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "pendingLostTaskReminderTaskIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    }
                                  },
                                  "nextTaskId": {
                                    "type": "number"
                                  },
                                  "wireGuardHorizon": {
                                    "type": "object",
                                    "properties": {
                                      "evictionHorizon": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "evictionHorizon"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "routing": {
                                    "type": "object",
                                    "properties": {
                                      "saved": {
                                        "type": "object",
                                        "properties": {
                                          "tier": {
                                            "type": "string"
                                          },
                                          "route": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "tier",
                                          "route"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "compactedSinceLastMessage": {
                                        "type": "boolean"
                                      },
                                      "currentTask": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "status",
                                  "mode",
                                  "agent"
                                ],
                                "additionalProperties": false
                              },
                              "questions": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "question": {
                                      "type": "string"
                                    },
                                    "header": {
                                      "type": "string"
                                    },
                                    "options": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "label": {
                                            "type": "string"
                                          },
                                          "description": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "label"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "multiSelect": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": [
                                    "question",
                                    "options"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "state",
                              "questions"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "interrupted"
                              },
                              "state": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting_for_human",
                                      "sleeping",
                                      "interrupted",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "mode": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "const": "agent"
                                      },
                                      {
                                        "type": "string",
                                        "const": "auto"
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "options": {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "type": "string"
                                      },
                                      "memoryModel": {
                                        "type": "string"
                                      },
                                      "thinkingLevel": {
                                        "type": "string",
                                        "enum": [
                                          "minimal",
                                          "low",
                                          "medium",
                                          "high",
                                          "xhigh"
                                        ]
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "agent": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "messages": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "role": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "role"
                                          ],
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "messages"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "stateMachine": {
                                    "type": "object",
                                    "properties": {
                                      "definition": {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "currentState": {
                                        "type": "string"
                                      },
                                      "currentInput": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "progress": {
                                        "type": "object",
                                        "properties": {
                                          "states": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "states"
                                        ],
                                        "additionalProperties": {}
                                      },
                                      "history": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      },
                                      "terminal": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "terminalAcknowledged": {
                                        "type": "boolean"
                                      },
                                      "createdAt": {
                                        "type": "number"
                                      },
                                      "updatedAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "definition",
                                      "prompt",
                                      "history",
                                      "createdAt",
                                      "updatedAt"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "pendingStateTransition": {
                                    "type": "object",
                                    "properties": {
                                      "stateName": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "stateName"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "todos": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "content": {
                                          "type": "string"
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "pending",
                                            "in_progress",
                                            "completed",
                                            "failed"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "content",
                                        "status"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "followUpQueue": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "message"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "queuedCommands": {
                                    "type": "array",
                                    "items": {
                                      "oneOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "prompt"
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "message",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "answer"
                                            },
                                            "questions": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "question": {
                                                    "type": "string"
                                                  },
                                                  "header": {
                                                    "type": "string"
                                                  },
                                                  "options": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "object",
                                                      "properties": {
                                                        "label": {
                                                          "type": "string"
                                                        },
                                                        "description": {
                                                          "type": "string"
                                                        }
                                                      },
                                                      "required": [
                                                        "label"
                                                      ],
                                                      "additionalProperties": false
                                                    }
                                                  },
                                                  "multiSelect": {
                                                    "type": "boolean"
                                                  }
                                                },
                                                "required": [
                                                  "question",
                                                  "options"
                                                ],
                                                "additionalProperties": false
                                              }
                                            },
                                            "answers": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              }
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "questions",
                                            "answers",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "wake"
                                            }
                                          },
                                          "required": [
                                            "type"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "tasks": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "kind": {
                                          "type": "string",
                                          "enum": [
                                            "tool",
                                            "subagent",
                                            "scheduled"
                                          ]
                                        },
                                        "name": {
                                          "type": "string"
                                        },
                                        "label": {
                                          "type": "string"
                                        },
                                        "ownerScopeId": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "pattern": "^turn-\\d+$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^task:t\\d+$"
                                            }
                                          ]
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "running",
                                            "scheduled",
                                            "completed",
                                            "failed",
                                            "stopped",
                                            "lost"
                                          ]
                                        },
                                        "startedAt": {
                                          "type": "number"
                                        },
                                        "wakeAt": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "kind",
                                        "name",
                                        "label",
                                        "ownerScopeId",
                                        "status",
                                        "startedAt"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "taskOutputTails": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "pendingLostTaskReminderTaskIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    }
                                  },
                                  "nextTaskId": {
                                    "type": "number"
                                  },
                                  "wireGuardHorizon": {
                                    "type": "object",
                                    "properties": {
                                      "evictionHorizon": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "evictionHorizon"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "routing": {
                                    "type": "object",
                                    "properties": {
                                      "saved": {
                                        "type": "object",
                                        "properties": {
                                          "tier": {
                                            "type": "string"
                                          },
                                          "route": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "tier",
                                          "route"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "compactedSinceLastMessage": {
                                        "type": "boolean"
                                      },
                                      "currentTask": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "status",
                                  "mode",
                                  "agent"
                                ],
                                "additionalProperties": false
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "state"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "sleep"
                              },
                              "state": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting_for_human",
                                      "sleeping",
                                      "interrupted",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "mode": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "const": "agent"
                                      },
                                      {
                                        "type": "string",
                                        "const": "auto"
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "options": {
                                    "type": "object",
                                    "properties": {
                                      "model": {
                                        "type": "string"
                                      },
                                      "memoryModel": {
                                        "type": "string"
                                      },
                                      "thinkingLevel": {
                                        "type": "string",
                                        "enum": [
                                          "minimal",
                                          "low",
                                          "medium",
                                          "high",
                                          "xhigh"
                                        ]
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "agent": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "messages": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "role": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "role"
                                          ],
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "messages"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "stateMachine": {
                                    "type": "object",
                                    "properties": {
                                      "definition": {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "currentState": {
                                        "type": "string"
                                      },
                                      "currentInput": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "progress": {
                                        "type": "object",
                                        "properties": {
                                          "states": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "states"
                                        ],
                                        "additionalProperties": {}
                                      },
                                      "history": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      },
                                      "terminal": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "terminalAcknowledged": {
                                        "type": "boolean"
                                      },
                                      "createdAt": {
                                        "type": "number"
                                      },
                                      "updatedAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "definition",
                                      "prompt",
                                      "history",
                                      "createdAt",
                                      "updatedAt"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "pendingStateTransition": {
                                    "type": "object",
                                    "properties": {
                                      "stateName": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "stateName"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "todos": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "content": {
                                          "type": "string"
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "pending",
                                            "in_progress",
                                            "completed",
                                            "failed"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "content",
                                        "status"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "followUpQueue": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "message"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "queuedCommands": {
                                    "type": "array",
                                    "items": {
                                      "oneOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "prompt"
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "message",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "answer"
                                            },
                                            "questions": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "question": {
                                                    "type": "string"
                                                  },
                                                  "header": {
                                                    "type": "string"
                                                  },
                                                  "options": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "object",
                                                      "properties": {
                                                        "label": {
                                                          "type": "string"
                                                        },
                                                        "description": {
                                                          "type": "string"
                                                        }
                                                      },
                                                      "required": [
                                                        "label"
                                                      ],
                                                      "additionalProperties": false
                                                    }
                                                  },
                                                  "multiSelect": {
                                                    "type": "boolean"
                                                  }
                                                },
                                                "required": [
                                                  "question",
                                                  "options"
                                                ],
                                                "additionalProperties": false
                                              }
                                            },
                                            "answers": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              }
                                            },
                                            "behavior": {
                                              "type": "string",
                                              "enum": [
                                                "steer",
                                                "follow_up"
                                              ]
                                            },
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "questions",
                                            "answers",
                                            "behavior"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "wake"
                                            }
                                          },
                                          "required": [
                                            "type"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "tasks": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "kind": {
                                          "type": "string",
                                          "enum": [
                                            "tool",
                                            "subagent",
                                            "scheduled"
                                          ]
                                        },
                                        "name": {
                                          "type": "string"
                                        },
                                        "label": {
                                          "type": "string"
                                        },
                                        "ownerScopeId": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "pattern": "^turn-\\d+$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^task:t\\d+$"
                                            }
                                          ]
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "running",
                                            "scheduled",
                                            "completed",
                                            "failed",
                                            "stopped",
                                            "lost"
                                          ]
                                        },
                                        "startedAt": {
                                          "type": "number"
                                        },
                                        "wakeAt": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "kind",
                                        "name",
                                        "label",
                                        "ownerScopeId",
                                        "status",
                                        "startedAt"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "taskOutputTails": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "pendingLostTaskReminderTaskIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    }
                                  },
                                  "nextTaskId": {
                                    "type": "number"
                                  },
                                  "wireGuardHorizon": {
                                    "type": "object",
                                    "properties": {
                                      "evictionHorizon": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "evictionHorizon"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "routing": {
                                    "type": "object",
                                    "properties": {
                                      "saved": {
                                        "type": "object",
                                        "properties": {
                                          "tier": {
                                            "type": "string"
                                          },
                                          "route": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "tier",
                                          "route"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "compactedSinceLastMessage": {
                                        "type": "boolean"
                                      },
                                      "currentTask": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "status",
                                  "mode",
                                  "agent"
                                ],
                                "additionalProperties": false
                              },
                              "wakeAt": {
                                "type": "number"
                              },
                              "pollWake": {
                                "type": "boolean"
                              },
                              "quiet": {
                                "type": "boolean",
                                "const": true
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "state",
                              "wakeAt"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      },
                      {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "turn_started"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "complete"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "result": {
                                "type": "string"
                              },
                              "error": {
                                "type": "string"
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "ask"
                              },
                              "status": {
                                "type": "string",
                                "const": "ask"
                              },
                              "questions": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "question": {
                                      "type": "string"
                                    },
                                    "header": {
                                      "type": "string"
                                    },
                                    "options": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "label": {
                                            "type": "string"
                                          },
                                          "description": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "label"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "multiSelect": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": [
                                    "question",
                                    "options"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "questions"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "interrupted"
                              },
                              "status": {
                                "type": "string",
                                "const": "interrupted"
                              },
                              "error": {
                                "type": "string"
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "sleep"
                              },
                              "status": {
                                "type": "string",
                                "const": "sleep"
                              },
                              "wakeAt": {
                                "type": "number"
                              },
                              "pollWake": {
                                "type": "boolean"
                              },
                              "turnUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "usageByModel": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "transport": {
                                      "type": "object",
                                      "properties": {
                                        "provider": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "duet-gateway",
                                                "vercel-ai-gateway",
                                                "openrouter"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "openai-codex",
                                                "github-copilot"
                                              ]
                                            }
                                          ]
                                        },
                                        "billing": {
                                          "type": "string",
                                          "enum": [
                                            "plan-covered",
                                            "metered"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "provider",
                                        "billing"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "usage": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "cacheWrite1h": {
                                          "type": "number"
                                        },
                                        "totalTokens": {
                                          "type": "number"
                                        },
                                        "cost": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "total": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "total"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "totalTokens",
                                        "cost"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "model",
                                    "transport",
                                    "usage"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "lastMessageUsage": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "cacheWrite1h": {
                                    "type": "number"
                                  },
                                  "totalTokens": {
                                    "type": "number"
                                  },
                                  "cost": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "total": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "total"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "totalTokens",
                                  "cost"
                                ],
                                "additionalProperties": false
                              },
                              "effectiveContextWindow": {
                                "type": "number"
                              },
                              "contextWindowUsage": {
                                "type": "object",
                                "properties": {
                                  "systemPrompt": {
                                    "type": "number"
                                  },
                                  "messages": {
                                    "type": "number"
                                  },
                                  "localMemory": {
                                    "type": "number"
                                  },
                                  "globalMemory": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "systemPrompt",
                                  "messages",
                                  "localMemory",
                                  "globalMemory"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "type",
                              "wakeAt"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "session_created"
                          },
                          "prompt": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "clientRequestId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          }
                        },
                        "required": [
                          "type",
                          "prompt",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "interrupt_requested"
                          },
                          "requestedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "type",
                          "requestedAt"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "agent_message"
                          },
                          "message": {
                            "type": "string",
                            "minLength": 1
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "type",
                          "message",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "view_shown"
                          },
                          "view": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "type",
                          "view",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "prompt_submitted"
                              },
                              "prompt": {
                                "type": "string"
                              },
                              "inputKind": {
                                "type": "string",
                                "enum": [
                                  "initial",
                                  "message"
                                ]
                              },
                              "behavior": {
                                "type": "string",
                                "enum": [
                                  "steer",
                                  "follow_up"
                                ]
                              },
                              "sender": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "user"
                                      },
                                      "userId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "userId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "app"
                                      },
                                      "appId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "appId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "session"
                                      },
                                      "sessionId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "sessionId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "system"
                                      }
                                    },
                                    "required": [
                                      "kind"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "clientRequestId": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                              },
                              "images": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "storageId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "mimeType": {
                                      "type": "string",
                                      "enum": [
                                        "image/png",
                                        "image/jpeg",
                                        "image/webp",
                                        "image/gif"
                                      ]
                                    },
                                    "bytes": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 5242880
                                    }
                                  },
                                  "required": [
                                    "storageId",
                                    "mimeType",
                                    "bytes"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "attachments": {
                                "maxItems": 10,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "path": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "name": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 255
                                    },
                                    "bytes": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "mimeType": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "path",
                                    "name",
                                    "bytes"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "dictated": {
                                "type": "boolean",
                                "const": true
                              }
                            },
                            "required": [
                              "type",
                              "prompt",
                              "inputKind",
                              "behavior",
                              "sender"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "note_submitted"
                              },
                              "note": {
                                "type": "string"
                              },
                              "sender": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "user"
                                      },
                                      "userId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "userId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "app"
                                      },
                                      "appId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "appId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "session"
                                      },
                                      "sessionId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "sessionId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "system"
                                      }
                                    },
                                    "required": [
                                      "kind"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "clientRequestId": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                              },
                              "images": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "storageId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "mimeType": {
                                      "type": "string",
                                      "enum": [
                                        "image/png",
                                        "image/jpeg",
                                        "image/webp",
                                        "image/gif"
                                      ]
                                    },
                                    "bytes": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 5242880
                                    }
                                  },
                                  "required": [
                                    "storageId",
                                    "mimeType",
                                    "bytes"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "attachments": {
                                "maxItems": 10,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "path": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "name": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 255
                                    },
                                    "bytes": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "mimeType": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "path",
                                    "name",
                                    "bytes"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "dictated": {
                                "type": "boolean",
                                "const": true
                              }
                            },
                            "required": [
                              "type",
                              "note",
                              "sender"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "answer_submitted"
                              },
                              "answer": {
                                "type": "string"
                              },
                              "sender": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "user"
                                      },
                                      "userId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "userId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "app"
                                      },
                                      "appId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "appId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "session"
                                      },
                                      "sessionId": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "required": [
                                      "kind",
                                      "sessionId"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "system"
                                      }
                                    },
                                    "required": [
                                      "kind"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "clientRequestId": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                              },
                              "images": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "storageId": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "mimeType": {
                                      "type": "string",
                                      "enum": [
                                        "image/png",
                                        "image/jpeg",
                                        "image/webp",
                                        "image/gif"
                                      ]
                                    },
                                    "bytes": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 5242880
                                    }
                                  },
                                  "required": [
                                    "storageId",
                                    "mimeType",
                                    "bytes"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "attachments": {
                                "maxItems": 10,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "path": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "name": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 255
                                    },
                                    "bytes": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "mimeType": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "path",
                                    "name",
                                    "bytes"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "dictated": {
                                "type": "boolean",
                                "const": true
                              }
                            },
                            "required": [
                              "type",
                              "answer",
                              "sender"
                            ],
                            "additionalProperties": false
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type"
                    ],
                    "additionalProperties": {}
                  }
                ]
              },
              "createdAt": {
                "type": "number"
              }
            },
            "required": [
              "seq",
              "event",
              "createdAt"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "events"
      ],
      "additionalProperties": false
    },
    "dispatched": {
      "type": "boolean",
      "const": false
    },
    "delivery": {
      "type": "string",
      "enum": [
        "accepted",
        "queued"
      ]
    }
  },
  "required": [
    "url",
    "session",
    "snapshot",
    "history",
    "dispatched",
    "delivery"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/children/wait

Create a child session and wait for the submitted turn to finish

CLI
bento session child create --session-id example --prompt "..." --agent seo-specialist
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "prompt": {
      "type": "string",
      "description": "The words of the input. May be empty when it carries images or attachments."
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "clientRequestId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "agent": {
      "description": "The agent that owns the session, by slug; `root` is the workspace agent. The session runs in the agent's folder. Not with cwd.",
      "type": "string"
    },
    "cwd": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024,
      "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
    },
    "images": {
      "maxItems": 4,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "minLength": 1
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp",
              "image/gif"
            ]
          }
        },
        "required": [
          "data",
          "mimeType"
        ]
      }
    },
    "attachments": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "mimeType": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "path",
          "name",
          "bytes"
        ]
      }
    },
    "dictated": {
      "description": "True when the words were transcribed from speech.",
      "type": "boolean"
    },
    "tier": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "behavior": {
      "default": "steer",
      "type": "string",
      "enum": [
        "steer",
        "follow_up"
      ]
    },
    "mode": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "prompt": {
          "type": "string"
        },
        "states": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        }
      },
      "required": [
        "name",
        "prompt",
        "states"
      ]
    }
  },
  "required": [
    "prompt",
    "clientRequestId"
  ],
  "additionalProperties": false
}
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "waitMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 720000
    }
  }
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "cwd": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
        },
        "terminal": {
          "type": "object",
          "properties": {
            "seq": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "event": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "step"
                            },
                            "step": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call_start"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "isError": {
                                      "type": "boolean"
                                    },
                                    "output": {
                                      "type": "array",
                                      "items": {
                                        "oneOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "text"
                                              },
                                              "text": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "text"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "image"
                                              },
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "details": {}
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId",
                                    "isError"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "system"
                                    },
                                    "message": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "step"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_started"
                            },
                            "task": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "tool",
                                    "subagent",
                                    "scheduled"
                                  ]
                                },
                                "name": {
                                  "type": "string"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "ownerScopeId": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "pattern": "^turn-\\d+$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^task:t\\d+$"
                                    }
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "scheduled",
                                    "completed",
                                    "failed",
                                    "stopped",
                                    "lost"
                                  ]
                                },
                                "startedAt": {
                                  "type": "number"
                                },
                                "wakeAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "id",
                                "kind",
                                "name",
                                "label",
                                "ownerScopeId",
                                "status",
                                "startedAt"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "task"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_output"
                            },
                            "taskId": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "chunk": {
                              "type": "string"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "taskId",
                            "chunk"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_settled"
                            },
                            "settlement": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "completed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "result": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "result"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "failed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "error": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "error"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "stopped"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "reason": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "reason"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "lost"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "settlement"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "heartbeat"
                            },
                            "timestamp": {
                              "type": "number"
                            },
                            "activeTaskIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            }
                          },
                          "required": [
                            "type",
                            "timestamp",
                            "activeTaskIds"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "todos"
                            },
                            "todos": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "in_progress",
                                      "completed",
                                      "failed"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "content",
                                  "status"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "todos"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "follow_up_queue"
                            },
                            "followUpQueue": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "message"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "followUpQueue"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "state_machine"
                            },
                            "stateMachine": {
                              "type": "object",
                              "properties": {
                                "definition": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "states": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "prompt",
                                    "states"
                                  ],
                                  "additionalProperties": false
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "currentState": {
                                  "type": "string"
                                },
                                "currentInput": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "progress": {
                                  "type": "object",
                                  "properties": {
                                    "states": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "states"
                                  ],
                                  "additionalProperties": {}
                                },
                                "history": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "terminal": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "terminalAcknowledged": {
                                  "type": "boolean"
                                },
                                "createdAt": {
                                  "type": "number"
                                },
                                "updatedAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "definition",
                                "prompt",
                                "history",
                                "createdAt",
                                "updatedAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "stateMachine"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "memory"
                            },
                            "phase": {
                              "type": "string",
                              "enum": [
                                "observation",
                                "reflection"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "completed"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "observations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "usageBumpedObservations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "type",
                            "phase",
                            "status",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "usage"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "turnUsage",
                            "usageByModel",
                            "lastMessageUsage",
                            "effectiveContextWindow",
                            "contextWindowUsage"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "system"
                            },
                            "level": {
                              "type": "string",
                              "enum": [
                                "debug",
                                "info",
                                "warn",
                                "error"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "providerRecovery": {
                              "type": "object",
                              "properties": {
                                "fromModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "fromRoute": {
                                  "type": "string",
                                  "enum": [
                                    "configured",
                                    "vercel",
                                    "unknown"
                                  ]
                                },
                                "toModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "toRoute": {
                                  "type": "string",
                                  "const": "vercel"
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "empty_response",
                                    "provider_error"
                                  ]
                                },
                                "status": {
                                  "type": "integer",
                                  "minimum": 100,
                                  "maximum": 599
                                }
                              },
                              "required": [
                                "fromModel",
                                "fromRoute",
                                "toModel",
                                "toRoute",
                                "reason"
                              ],
                              "additionalProperties": false
                            },
                            "metadata": {
                              "type": "object",
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "enum": [
                                    "storage_full",
                                    "session_cwd_fallback",
                                    "bound_agent_root_unavailable",
                                    "relay_backlog",
                                    "runner_exited",
                                    "relay_undeliverable",
                                    "interrupt_undeliverable"
                                  ]
                                }
                              },
                              "required": [
                                "code"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "level",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "router_switch"
                            },
                            "tier": {
                              "type": "string"
                            },
                            "route": {
                              "type": "string"
                            },
                            "fromModel": {
                              "type": "string"
                            },
                            "toModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            },
                            "trigger": {
                              "type": "string",
                              "enum": [
                                "first_turn",
                                "new_task",
                                "idle",
                                "manual_compact",
                                "overflow",
                                "modality_switch",
                                "tier_change"
                              ]
                            },
                            "rationale": {
                              "type": "string"
                            },
                            "probabilities": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "visionFallback": {
                              "type": "boolean"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "tier",
                            "route",
                            "fromModel",
                            "toModel",
                            "thinkingLevel",
                            "trigger",
                            "visionFallback"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "status"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "quiet": {
                              "type": "boolean",
                              "const": true
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "status": {
                              "type": "string",
                              "const": "ask"
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "status": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "status": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "session_created"
                        },
                        "prompt": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "clientRequestId": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "required": [
                        "type",
                        "prompt",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "interrupt_requested"
                        },
                        "requestedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "requestedAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "agent_message"
                        },
                        "message": {
                          "type": "string",
                          "minLength": 1
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "view_shown"
                        },
                        "view": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "view",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "prompt_submitted"
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "inputKind": {
                              "type": "string",
                              "enum": [
                                "initial",
                                "message"
                              ]
                            },
                            "behavior": {
                              "type": "string",
                              "enum": [
                                "steer",
                                "follow_up"
                              ]
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "prompt",
                            "inputKind",
                            "behavior",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "note_submitted"
                            },
                            "note": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "note",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "answer_submitted"
                            },
                            "answer": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "answer",
                            "sender"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    }
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": {}
                }
              ]
            },
            "createdAt": {
              "type": "number"
            }
          },
          "required": [
            "seq",
            "event",
            "createdAt"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "sessionId",
        "inputSeq",
        "url",
        "terminal"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "status": {
          "type": "string",
          "const": "running"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [
        "sessionId",
        "inputSeq",
        "status",
        "url"
      ],
      "additionalProperties": false
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/children

Page one sessionโ€™s direct children

CLI
bento session child list --session-id example
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "bucket": {
      "type": "string",
      "enum": [
        "asking",
        "running",
        "scheduled",
        "done"
      ]
    },
    "archived": {
      "default": "exclude",
      "type": "string",
      "enum": [
        "exclude",
        "only"
      ]
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "pinned": {
            "type": "boolean"
          },
          "pin": {
            "type": "object",
            "properties": {
              "pinned": {
                "type": "boolean"
              },
              "version": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "pinned",
              "version"
            ],
            "additionalProperties": false
          },
          "turnStatus": {
            "type": "string",
            "enum": [
              "running",
              "complete",
              "ask",
              "interrupted",
              "sleep"
            ]
          },
          "turnError": {
            "type": "string"
          },
          "bucket": {
            "type": "string",
            "enum": [
              "asking",
              "running",
              "scheduled",
              "done"
            ]
          },
          "title": {
            "type": "string"
          },
          "titleOrigin": {
            "type": "string",
            "enum": [
              "excerpt",
              "auto",
              "manual"
            ]
          },
          "titleStatus": {
            "type": "string",
            "enum": [
              "generating",
              "complete",
              "failed"
            ]
          },
          "cwd": {
            "type": "string"
          },
          "agent": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "slug": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "name"
            ],
            "additionalProperties": false
          },
          "onboarding": {
            "type": "boolean"
          },
          "createdBySessionId": {
            "type": "string"
          },
          "createdAt": {
            "type": "number"
          },
          "updatedAt": {
            "type": "number"
          },
          "lastEventSeq": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "unread": {
            "type": "boolean"
          },
          "audience": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "workspace"
                  }
                },
                "required": [
                  "kind"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "specific"
                  },
                  "count": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "preview": {
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "memberId": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string",
                          "format": "email",
                          "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "owner",
                            "editor",
                            "viewer"
                          ]
                        }
                      },
                      "required": [
                        "memberId",
                        "userId",
                        "name",
                        "email",
                        "role"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "kind",
                  "count",
                  "preview"
                ],
                "additionalProperties": false
              }
            ]
          },
          "archive": {
            "type": "object",
            "properties": {
              "globalArchivedAt": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "globalArchiveOrigin": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "manual",
                      "automatic"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "personalArchivedAt": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reason": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "global",
                      "personal"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "globalArchivedAt",
              "globalArchiveOrigin",
              "personalArchivedAt",
              "reason"
            ],
            "additionalProperties": false
          },
          "permissions": {
            "type": "object",
            "properties": {
              "send": {
                "type": "boolean"
              },
              "answer": {
                "type": "boolean"
              },
              "interrupt": {
                "type": "boolean"
              },
              "rename": {
                "type": "boolean"
              },
              "pin": {
                "type": "boolean"
              },
              "manageAudience": {
                "type": "boolean"
              },
              "personalArchive": {
                "type": "boolean"
              },
              "globalArchive": {
                "type": "boolean"
              },
              "delete": {
                "type": "boolean"
              }
            },
            "required": [
              "send",
              "answer",
              "interrupt",
              "rename",
              "pin",
              "manageAudience",
              "personalArchive",
              "globalArchive",
              "delete"
            ],
            "additionalProperties": false
          },
          "view": {
            "type": "string"
          },
          "viewRevision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "viewBy": {
            "type": "string",
            "enum": [
              "user",
              "agent"
            ]
          },
          "machine": {
            "type": "object",
            "properties": {
              "step": {
                "type": "string"
              },
              "progress": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "total": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "completed",
                  "total"
                ],
                "additionalProperties": false
              },
              "activity": {
                "type": "string",
                "enum": [
                  "running",
                  "sleeping",
                  "waiting",
                  "idle"
                ]
              },
              "nextWakeAt": {
                "type": "number"
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "interrupted",
                  "completed",
                  "failed",
                  "cancelled",
                  "error"
                ]
              }
            },
            "required": [
              "activity"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "pinned",
          "turnStatus",
          "bucket",
          "title",
          "titleOrigin",
          "titleStatus",
          "createdAt",
          "updatedAt",
          "lastEventSeq",
          "unread",
          "audience",
          "archive",
          "permissions"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Opaque collection cursor is malformed or bound to another walk (400)
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "const": "invalid_cursor"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false,
  "description": "Opaque collection cursor is malformed or bound to another walk (400)"
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions/{sessionId}

Get a session snapshot

CLI
bento session get --session-id example
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "pinned": {
      "type": "boolean"
    },
    "pin": {
      "type": "object",
      "properties": {
        "pinned": {
          "type": "boolean"
        },
        "version": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "pinned",
        "version"
      ],
      "additionalProperties": false
    },
    "turnStatus": {
      "type": "string",
      "enum": [
        "running",
        "complete",
        "ask",
        "interrupted",
        "sleep"
      ]
    },
    "turnError": {
      "type": "string"
    },
    "bucket": {
      "type": "string",
      "enum": [
        "asking",
        "running",
        "scheduled",
        "done"
      ]
    },
    "title": {
      "type": "string"
    },
    "titleOrigin": {
      "type": "string",
      "enum": [
        "excerpt",
        "auto",
        "manual"
      ]
    },
    "titleStatus": {
      "type": "string",
      "enum": [
        "generating",
        "complete",
        "failed"
      ]
    },
    "cwd": {
      "type": "string"
    },
    "agent": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "slug": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "name"
      ],
      "additionalProperties": false
    },
    "onboarding": {
      "type": "boolean"
    },
    "createdBySessionId": {
      "type": "string"
    },
    "machine": {
      "type": "object",
      "properties": {
        "definitionName": {
          "type": "string"
        },
        "currentState": {
          "type": "string"
        },
        "followingDefinitionState": {
          "type": "string"
        },
        "progress": {
          "type": "object",
          "properties": {
            "completed": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "total": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "completed",
            "total"
          ],
          "additionalProperties": false
        },
        "orderedPath": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "key": {
                "type": "string"
              },
              "index": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "name": {
                "type": "string"
              },
              "kind": {
                "type": "string"
              },
              "phase": {
                "type": "string",
                "enum": [
                  "past",
                  "current",
                  "future",
                  "outcome"
                ]
              },
              "terminalStatus": {
                "type": "string",
                "enum": [
                  "completed",
                  "failed",
                  "cancelled",
                  "error"
                ]
              }
            },
            "required": [
              "key",
              "index",
              "name",
              "phase"
            ],
            "additionalProperties": false
          }
        },
        "activity": {
          "type": "string",
          "enum": [
            "running",
            "sleeping",
            "waiting",
            "idle"
          ]
        },
        "nextWakeAt": {
          "type": "number"
        },
        "pollIntervalMs": {
          "type": "number"
        },
        "outcome": {
          "type": "string",
          "enum": [
            "interrupted",
            "completed",
            "failed",
            "cancelled",
            "error"
          ]
        }
      },
      "required": [
        "orderedPath",
        "activity"
      ],
      "additionalProperties": false
    },
    "createdAt": {
      "type": "number"
    },
    "updatedAt": {
      "type": "number"
    },
    "lastEventSeq": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "unread": {
      "type": "boolean"
    },
    "audience": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "workspace"
            }
          },
          "required": [
            "kind"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "specific"
            },
            "count": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "preview": {
              "maxItems": 5,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "memberId": {
                    "type": "string"
                  },
                  "userId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "owner",
                      "editor",
                      "viewer"
                    ]
                  }
                },
                "required": [
                  "memberId",
                  "userId",
                  "name",
                  "email",
                  "role"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "kind",
            "count",
            "preview"
          ],
          "additionalProperties": false
        }
      ]
    },
    "archive": {
      "type": "object",
      "properties": {
        "globalArchivedAt": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "globalArchiveOrigin": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "manual",
                "automatic"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "personalArchivedAt": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "reason": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "global",
                "personal"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "globalArchivedAt",
        "globalArchiveOrigin",
        "personalArchivedAt",
        "reason"
      ],
      "additionalProperties": false
    },
    "permissions": {
      "type": "object",
      "properties": {
        "send": {
          "type": "boolean"
        },
        "answer": {
          "type": "boolean"
        },
        "interrupt": {
          "type": "boolean"
        },
        "rename": {
          "type": "boolean"
        },
        "pin": {
          "type": "boolean"
        },
        "manageAudience": {
          "type": "boolean"
        },
        "personalArchive": {
          "type": "boolean"
        },
        "globalArchive": {
          "type": "boolean"
        },
        "delete": {
          "type": "boolean"
        }
      },
      "required": [
        "send",
        "answer",
        "interrupt",
        "rename",
        "pin",
        "manageAudience",
        "personalArchive",
        "globalArchive",
        "delete"
      ],
      "additionalProperties": false
    },
    "view": {
      "type": "string"
    },
    "viewRevision": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "viewBy": {
      "type": "string",
      "enum": [
        "user",
        "agent"
      ]
    },
    "workspaceId": {
      "type": "string"
    },
    "tier": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "lastDeliveredInputSeq": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "deliveryAttempt": {
      "type": "object",
      "properties": {
        "attemptId": {
          "type": "string",
          "minLength": 1
        },
        "throughSeq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "kind": {
          "type": "string",
          "enum": [
            "initial_prompt",
            "message",
            "answer"
          ]
        },
        "createdAt": {
          "type": "number"
        }
      },
      "required": [
        "attemptId",
        "throughSeq",
        "kind",
        "createdAt"
      ],
      "additionalProperties": false
    },
    "todos": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "content": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "in_progress",
              "completed",
              "failed"
            ]
          }
        },
        "required": [
          "id",
          "content",
          "status"
        ],
        "additionalProperties": false
      }
    },
    "followUpQueue": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "images": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "data": {
                  "type": "string"
                },
                "mimeType": {
                  "type": "string"
                }
              },
              "required": [
                "data",
                "mimeType"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "message"
        ],
        "additionalProperties": false
      }
    },
    "requestedMachine": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "prompt": {
          "type": "string"
        },
        "states": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        }
      },
      "required": [
        "name",
        "prompt",
        "states"
      ],
      "additionalProperties": false
    },
    "machineState": {
      "type": "object",
      "properties": {
        "definition": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "prompt": {
              "type": "string"
            },
            "states": {
              "type": "array",
              "items": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              }
            }
          },
          "required": [
            "name",
            "prompt",
            "states"
          ],
          "additionalProperties": false
        },
        "prompt": {
          "type": "string"
        },
        "currentState": {
          "type": "string"
        },
        "currentInput": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        "progress": {
          "type": "object",
          "properties": {
            "states": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              }
            }
          },
          "required": [
            "states"
          ],
          "additionalProperties": {}
        },
        "history": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "terminal": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        "terminalAcknowledged": {
          "type": "boolean"
        },
        "createdAt": {
          "type": "number"
        },
        "updatedAt": {
          "type": "number"
        }
      },
      "required": [
        "definition",
        "prompt",
        "history",
        "createdAt",
        "updatedAt"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "id",
    "pinned",
    "turnStatus",
    "bucket",
    "title",
    "titleOrigin",
    "titleStatus",
    "createdAt",
    "updatedAt",
    "lastEventSeq",
    "unread",
    "audience",
    "archive",
    "permissions",
    "workspaceId",
    "lastDeliveredInputSeq"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/agents/{agentSlug}/sessions/default

Get an agent's default session snapshot

CLI
bento agent session default get --agent-slug seo-specialist
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "session": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "pinned": {
              "type": "boolean"
            },
            "pin": {
              "type": "object",
              "properties": {
                "pinned": {
                  "type": "boolean"
                },
                "version": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "pinned",
                "version"
              ],
              "additionalProperties": false
            },
            "turnStatus": {
              "type": "string",
              "enum": [
                "running",
                "complete",
                "ask",
                "interrupted",
                "sleep"
              ]
            },
            "turnError": {
              "type": "string"
            },
            "bucket": {
              "type": "string",
              "enum": [
                "asking",
                "running",
                "scheduled",
                "done"
              ]
            },
            "title": {
              "type": "string"
            },
            "titleOrigin": {
              "type": "string",
              "enum": [
                "excerpt",
                "auto",
                "manual"
              ]
            },
            "titleStatus": {
              "type": "string",
              "enum": [
                "generating",
                "complete",
                "failed"
              ]
            },
            "cwd": {
              "type": "string"
            },
            "agent": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ],
              "additionalProperties": false
            },
            "onboarding": {
              "type": "boolean"
            },
            "createdBySessionId": {
              "type": "string"
            },
            "machine": {
              "type": "object",
              "properties": {
                "definitionName": {
                  "type": "string"
                },
                "currentState": {
                  "type": "string"
                },
                "followingDefinitionState": {
                  "type": "string"
                },
                "progress": {
                  "type": "object",
                  "properties": {
                    "completed": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "total": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "completed",
                    "total"
                  ],
                  "additionalProperties": false
                },
                "orderedPath": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "index": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "name": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string"
                      },
                      "phase": {
                        "type": "string",
                        "enum": [
                          "past",
                          "current",
                          "future",
                          "outcome"
                        ]
                      },
                      "terminalStatus": {
                        "type": "string",
                        "enum": [
                          "completed",
                          "failed",
                          "cancelled",
                          "error"
                        ]
                      }
                    },
                    "required": [
                      "key",
                      "index",
                      "name",
                      "phase"
                    ],
                    "additionalProperties": false
                  }
                },
                "activity": {
                  "type": "string",
                  "enum": [
                    "running",
                    "sleeping",
                    "waiting",
                    "idle"
                  ]
                },
                "nextWakeAt": {
                  "type": "number"
                },
                "pollIntervalMs": {
                  "type": "number"
                },
                "outcome": {
                  "type": "string",
                  "enum": [
                    "interrupted",
                    "completed",
                    "failed",
                    "cancelled",
                    "error"
                  ]
                }
              },
              "required": [
                "orderedPath",
                "activity"
              ],
              "additionalProperties": false
            },
            "createdAt": {
              "type": "number"
            },
            "updatedAt": {
              "type": "number"
            },
            "lastEventSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "unread": {
              "type": "boolean"
            },
            "audience": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "workspace"
                    }
                  },
                  "required": [
                    "kind"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "specific"
                    },
                    "count": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "preview": {
                      "maxItems": 5,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "memberId": {
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "role": {
                            "type": "string",
                            "enum": [
                              "owner",
                              "editor",
                              "viewer"
                            ]
                          }
                        },
                        "required": [
                          "memberId",
                          "userId",
                          "name",
                          "email",
                          "role"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "kind",
                    "count",
                    "preview"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "archive": {
              "type": "object",
              "properties": {
                "globalArchivedAt": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "globalArchiveOrigin": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "manual",
                        "automatic"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "personalArchivedAt": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reason": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "global",
                        "personal"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "globalArchivedAt",
                "globalArchiveOrigin",
                "personalArchivedAt",
                "reason"
              ],
              "additionalProperties": false
            },
            "permissions": {
              "type": "object",
              "properties": {
                "send": {
                  "type": "boolean"
                },
                "answer": {
                  "type": "boolean"
                },
                "interrupt": {
                  "type": "boolean"
                },
                "rename": {
                  "type": "boolean"
                },
                "pin": {
                  "type": "boolean"
                },
                "manageAudience": {
                  "type": "boolean"
                },
                "personalArchive": {
                  "type": "boolean"
                },
                "globalArchive": {
                  "type": "boolean"
                },
                "delete": {
                  "type": "boolean"
                }
              },
              "required": [
                "send",
                "answer",
                "interrupt",
                "rename",
                "pin",
                "manageAudience",
                "personalArchive",
                "globalArchive",
                "delete"
              ],
              "additionalProperties": false
            },
            "view": {
              "type": "string"
            },
            "viewRevision": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "viewBy": {
              "type": "string",
              "enum": [
                "user",
                "agent"
              ]
            },
            "workspaceId": {
              "type": "string"
            },
            "tier": {
              "type": "string",
              "enum": [
                "frontier",
                "balanced",
                "economy",
                "openai-frontier",
                "openai-max",
                "anthropic-frontier",
                "anthropic-max",
                "anthropic-balanced",
                "google-recommended",
                "google-balanced"
              ]
            },
            "lastDeliveredInputSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "deliveryAttempt": {
              "type": "object",
              "properties": {
                "attemptId": {
                  "type": "string",
                  "minLength": 1
                },
                "throughSeq": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "initial_prompt",
                    "message",
                    "answer"
                  ]
                },
                "createdAt": {
                  "type": "number"
                }
              },
              "required": [
                "attemptId",
                "throughSeq",
                "kind",
                "createdAt"
              ],
              "additionalProperties": false
            },
            "todos": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "in_progress",
                      "completed",
                      "failed"
                    ]
                  }
                },
                "required": [
                  "id",
                  "content",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "followUpQueue": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "string"
                        },
                        "mimeType": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "data",
                        "mimeType"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "message"
                ],
                "additionalProperties": false
              }
            },
            "requestedMachine": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "prompt": {
                  "type": "string"
                },
                "states": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                }
              },
              "required": [
                "name",
                "prompt",
                "states"
              ],
              "additionalProperties": false
            },
            "machineState": {
              "type": "object",
              "properties": {
                "definition": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "prompt": {
                      "type": "string"
                    },
                    "states": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "name",
                    "prompt",
                    "states"
                  ],
                  "additionalProperties": false
                },
                "prompt": {
                  "type": "string"
                },
                "currentState": {
                  "type": "string"
                },
                "currentInput": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "progress": {
                  "type": "object",
                  "properties": {
                    "states": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "states"
                  ],
                  "additionalProperties": {}
                },
                "history": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "terminal": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "terminalAcknowledged": {
                  "type": "boolean"
                },
                "createdAt": {
                  "type": "number"
                },
                "updatedAt": {
                  "type": "number"
                }
              },
              "required": [
                "definition",
                "prompt",
                "history",
                "createdAt",
                "updatedAt"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "id",
            "pinned",
            "turnStatus",
            "bucket",
            "title",
            "titleOrigin",
            "titleStatus",
            "createdAt",
            "updatedAt",
            "lastEventSeq",
            "unread",
            "audience",
            "archive",
            "permissions",
            "workspaceId",
            "lastDeliveredInputSeq"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "session"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
PUT/v1/workspaces/{workspaceSlug}/agents/{agentSlug}/sessions/default

Point an agent's default session alias at a session, or at nothing

CLI
bento agent session default update --agent-slug seo-specialist --body-file request.json
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "sessionId": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "sessionId"
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "session": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "pinned": {
              "type": "boolean"
            },
            "pin": {
              "type": "object",
              "properties": {
                "pinned": {
                  "type": "boolean"
                },
                "version": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "pinned",
                "version"
              ],
              "additionalProperties": false
            },
            "turnStatus": {
              "type": "string",
              "enum": [
                "running",
                "complete",
                "ask",
                "interrupted",
                "sleep"
              ]
            },
            "turnError": {
              "type": "string"
            },
            "bucket": {
              "type": "string",
              "enum": [
                "asking",
                "running",
                "scheduled",
                "done"
              ]
            },
            "title": {
              "type": "string"
            },
            "titleOrigin": {
              "type": "string",
              "enum": [
                "excerpt",
                "auto",
                "manual"
              ]
            },
            "titleStatus": {
              "type": "string",
              "enum": [
                "generating",
                "complete",
                "failed"
              ]
            },
            "cwd": {
              "type": "string"
            },
            "agent": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ],
              "additionalProperties": false
            },
            "onboarding": {
              "type": "boolean"
            },
            "createdBySessionId": {
              "type": "string"
            },
            "machine": {
              "type": "object",
              "properties": {
                "definitionName": {
                  "type": "string"
                },
                "currentState": {
                  "type": "string"
                },
                "followingDefinitionState": {
                  "type": "string"
                },
                "progress": {
                  "type": "object",
                  "properties": {
                    "completed": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "total": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "completed",
                    "total"
                  ],
                  "additionalProperties": false
                },
                "orderedPath": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "index": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "name": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string"
                      },
                      "phase": {
                        "type": "string",
                        "enum": [
                          "past",
                          "current",
                          "future",
                          "outcome"
                        ]
                      },
                      "terminalStatus": {
                        "type": "string",
                        "enum": [
                          "completed",
                          "failed",
                          "cancelled",
                          "error"
                        ]
                      }
                    },
                    "required": [
                      "key",
                      "index",
                      "name",
                      "phase"
                    ],
                    "additionalProperties": false
                  }
                },
                "activity": {
                  "type": "string",
                  "enum": [
                    "running",
                    "sleeping",
                    "waiting",
                    "idle"
                  ]
                },
                "nextWakeAt": {
                  "type": "number"
                },
                "pollIntervalMs": {
                  "type": "number"
                },
                "outcome": {
                  "type": "string",
                  "enum": [
                    "interrupted",
                    "completed",
                    "failed",
                    "cancelled",
                    "error"
                  ]
                }
              },
              "required": [
                "orderedPath",
                "activity"
              ],
              "additionalProperties": false
            },
            "createdAt": {
              "type": "number"
            },
            "updatedAt": {
              "type": "number"
            },
            "lastEventSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "unread": {
              "type": "boolean"
            },
            "audience": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "workspace"
                    }
                  },
                  "required": [
                    "kind"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "specific"
                    },
                    "count": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "preview": {
                      "maxItems": 5,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "memberId": {
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "role": {
                            "type": "string",
                            "enum": [
                              "owner",
                              "editor",
                              "viewer"
                            ]
                          }
                        },
                        "required": [
                          "memberId",
                          "userId",
                          "name",
                          "email",
                          "role"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "kind",
                    "count",
                    "preview"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "archive": {
              "type": "object",
              "properties": {
                "globalArchivedAt": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "globalArchiveOrigin": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "manual",
                        "automatic"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "personalArchivedAt": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reason": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "global",
                        "personal"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "globalArchivedAt",
                "globalArchiveOrigin",
                "personalArchivedAt",
                "reason"
              ],
              "additionalProperties": false
            },
            "permissions": {
              "type": "object",
              "properties": {
                "send": {
                  "type": "boolean"
                },
                "answer": {
                  "type": "boolean"
                },
                "interrupt": {
                  "type": "boolean"
                },
                "rename": {
                  "type": "boolean"
                },
                "pin": {
                  "type": "boolean"
                },
                "manageAudience": {
                  "type": "boolean"
                },
                "personalArchive": {
                  "type": "boolean"
                },
                "globalArchive": {
                  "type": "boolean"
                },
                "delete": {
                  "type": "boolean"
                }
              },
              "required": [
                "send",
                "answer",
                "interrupt",
                "rename",
                "pin",
                "manageAudience",
                "personalArchive",
                "globalArchive",
                "delete"
              ],
              "additionalProperties": false
            },
            "view": {
              "type": "string"
            },
            "viewRevision": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "viewBy": {
              "type": "string",
              "enum": [
                "user",
                "agent"
              ]
            },
            "workspaceId": {
              "type": "string"
            },
            "tier": {
              "type": "string",
              "enum": [
                "frontier",
                "balanced",
                "economy",
                "openai-frontier",
                "openai-max",
                "anthropic-frontier",
                "anthropic-max",
                "anthropic-balanced",
                "google-recommended",
                "google-balanced"
              ]
            },
            "lastDeliveredInputSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "deliveryAttempt": {
              "type": "object",
              "properties": {
                "attemptId": {
                  "type": "string",
                  "minLength": 1
                },
                "throughSeq": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "initial_prompt",
                    "message",
                    "answer"
                  ]
                },
                "createdAt": {
                  "type": "number"
                }
              },
              "required": [
                "attemptId",
                "throughSeq",
                "kind",
                "createdAt"
              ],
              "additionalProperties": false
            },
            "todos": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "in_progress",
                      "completed",
                      "failed"
                    ]
                  }
                },
                "required": [
                  "id",
                  "content",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "followUpQueue": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "string"
                        },
                        "mimeType": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "data",
                        "mimeType"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "message"
                ],
                "additionalProperties": false
              }
            },
            "requestedMachine": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "prompt": {
                  "type": "string"
                },
                "states": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                }
              },
              "required": [
                "name",
                "prompt",
                "states"
              ],
              "additionalProperties": false
            },
            "machineState": {
              "type": "object",
              "properties": {
                "definition": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "prompt": {
                      "type": "string"
                    },
                    "states": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "name",
                    "prompt",
                    "states"
                  ],
                  "additionalProperties": false
                },
                "prompt": {
                  "type": "string"
                },
                "currentState": {
                  "type": "string"
                },
                "currentInput": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "progress": {
                  "type": "object",
                  "properties": {
                    "states": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "states"
                  ],
                  "additionalProperties": {}
                },
                "history": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "terminal": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "terminalAcknowledged": {
                  "type": "boolean"
                },
                "createdAt": {
                  "type": "number"
                },
                "updatedAt": {
                  "type": "number"
                }
              },
              "required": [
                "definition",
                "prompt",
                "history",
                "createdAt",
                "updatedAt"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "id",
            "pinned",
            "turnStatus",
            "bucket",
            "title",
            "titleOrigin",
            "titleStatus",
            "createdAt",
            "updatedAt",
            "lastEventSeq",
            "unread",
            "audience",
            "archive",
            "permissions",
            "workspaceId",
            "lastDeliveredInputSeq"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "session"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "anyOf": [
        {
          "anyOf": [
            {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "error": {
                              "type": "string",
                              "const": "not_found"
                            }
                          },
                          "required": [
                            "error"
                          ],
                          "additionalProperties": false,
                          "description": "The session is unavailable to this caller (404)"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "error": {
                              "type": "string",
                              "const": "forbidden"
                            }
                          },
                          "required": [
                            "error"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "error": {
                          "type": "string",
                          "const": "default_session_wrong_owner"
                        }
                      },
                      "required": [
                        "error"
                      ],
                      "additionalProperties": false,
                      "description": "This chat belongs to another owner. Pick a chat owned by the selected agent, or update its own agent's default (409)."
                    }
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "default_session_archived"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false,
                  "description": "An archived chat can't be an agent's default. Restore it or pick an active chat this agent owns (409)."
                }
              ]
            },
            {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "default_session_onboarding"
                }
              },
              "required": [
                "error"
              ],
              "additionalProperties": false,
              "description": "An onboarding chat can't be an agent's default. Pick an ordinary chat this agent owns (409)."
            }
          ]
        },
        {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "const": "default_session_has_parent"
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false,
          "description": "A child session can't be an agent's default chat. Pick a top-level chat this agent owns (409)."
        }
      ]
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "default_session_not_workspace_wide"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "A specific-people chat can't be an agent's default. Pick a workspace-wide chat this agent owns (409)."
    }
  ]
}
Delivery
Standard response
Retry
Declared idempotent
GET/v1/workspaces/{workspaceSlug}/agents/{agentSlug}/sessions/default/history

Page through an agent's default session history

CLI
bento agent session default history list --agent-slug seo-specialist
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "order": {
      "default": "desc",
      "type": "string",
      "enum": [
        "asc",
        "desc"
      ]
    },
    "view": {
      "default": "all",
      "type": "string",
      "enum": [
        "all",
        "transcript"
      ]
    },
    "afterSeq": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "seq": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "event": {
            "anyOf": [
              {
                "anyOf": [
                  {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "turn_started"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "step"
                          },
                          "step": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "text_delta"
                                  },
                                  "delta": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "delta"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "reasoning_delta"
                                  },
                                  "delta": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "delta"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "text"
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "reasoning"
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "tool_call_start"
                                  },
                                  "toolName": {
                                    "type": "string"
                                  },
                                  "toolCallId": {
                                    "type": "string"
                                  },
                                  "input": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "toolName",
                                  "toolCallId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "tool_call"
                                  },
                                  "toolName": {
                                    "type": "string"
                                  },
                                  "toolCallId": {
                                    "type": "string"
                                  },
                                  "input": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "isError": {
                                    "type": "boolean"
                                  },
                                  "output": {
                                    "type": "array",
                                    "items": {
                                      "oneOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "text"
                                            },
                                            "text": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "text"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "image"
                                            },
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "details": {}
                                },
                                "required": [
                                  "type",
                                  "toolName",
                                  "toolCallId",
                                  "isError"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "system"
                                  },
                                  "message": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "message"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "step"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "task_started"
                          },
                          "task": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "tool",
                                  "subagent",
                                  "scheduled"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "ownerScopeId": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "pattern": "^turn-\\d+$"
                                  },
                                  {
                                    "type": "string",
                                    "pattern": "^task:t\\d+$"
                                  }
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "scheduled",
                                  "completed",
                                  "failed",
                                  "stopped",
                                  "lost"
                                ]
                              },
                              "startedAt": {
                                "type": "number"
                              },
                              "wakeAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "name",
                              "label",
                              "ownerScopeId",
                              "status",
                              "startedAt"
                            ],
                            "additionalProperties": false
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "task"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "task_output"
                          },
                          "taskId": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          },
                          "chunk": {
                            "type": "string"
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "taskId",
                          "chunk"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "task_settled"
                          },
                          "settlement": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "completed"
                                  },
                                  "settledAt": {
                                    "type": "number"
                                  },
                                  "result": {}
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "settledAt",
                                  "result"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "failed"
                                  },
                                  "settledAt": {
                                    "type": "number"
                                  },
                                  "error": {}
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "settledAt",
                                  "error"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "stopped"
                                  },
                                  "settledAt": {
                                    "type": "number"
                                  },
                                  "reason": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "settledAt",
                                  "reason"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "lost"
                                  },
                                  "settledAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "settledAt"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "settlement"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "heartbeat"
                          },
                          "timestamp": {
                            "type": "number"
                          },
                          "activeTaskIds": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            }
                          }
                        },
                        "required": [
                          "type",
                          "timestamp",
                          "activeTaskIds"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "todos"
                          },
                          "todos": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "content": {
                                  "type": "string"
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "pending",
                                    "in_progress",
                                    "completed",
                                    "failed"
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "content",
                                "status"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "type",
                          "todos"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "follow_up_queue"
                          },
                          "followUpQueue": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "message": {
                                  "type": "string"
                                },
                                "images": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "data": {
                                        "type": "string"
                                      },
                                      "mimeType": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "data",
                                      "mimeType"
                                    ],
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "message"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "type",
                          "followUpQueue"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "state_machine"
                          },
                          "stateMachine": {
                            "type": "object",
                            "properties": {
                              "definition": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "states": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "name",
                                  "prompt",
                                  "states"
                                ],
                                "additionalProperties": false
                              },
                              "prompt": {
                                "type": "string"
                              },
                              "currentState": {
                                "type": "string"
                              },
                              "currentInput": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              "progress": {
                                "type": "object",
                                "properties": {
                                  "states": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "states"
                                ],
                                "additionalProperties": {}
                              },
                              "history": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                }
                              },
                              "terminal": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              "terminalAcknowledged": {
                                "type": "boolean"
                              },
                              "createdAt": {
                                "type": "number"
                              },
                              "updatedAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "definition",
                              "prompt",
                              "history",
                              "createdAt",
                              "updatedAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "stateMachine"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "memory"
                          },
                          "phase": {
                            "type": "string",
                            "enum": [
                              "observation",
                              "reflection"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "running",
                              "completed"
                            ]
                          },
                          "message": {
                            "type": "string"
                          },
                          "observations": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            }
                          },
                          "usageBumpedObservations": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            }
                          }
                        },
                        "required": [
                          "type",
                          "phase",
                          "status",
                          "message"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "usage"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "turnUsage",
                          "usageByModel",
                          "lastMessageUsage",
                          "effectiveContextWindow",
                          "contextWindowUsage"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "system"
                          },
                          "level": {
                            "type": "string",
                            "enum": [
                              "debug",
                              "info",
                              "warn",
                              "error"
                            ]
                          },
                          "message": {
                            "type": "string"
                          },
                          "providerRecovery": {
                            "type": "object",
                            "properties": {
                              "fromModel": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "fromRoute": {
                                "type": "string",
                                "enum": [
                                  "configured",
                                  "vercel",
                                  "unknown"
                                ]
                              },
                              "toModel": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "toRoute": {
                                "type": "string",
                                "const": "vercel"
                              },
                              "reason": {
                                "type": "string",
                                "enum": [
                                  "empty_response",
                                  "provider_error"
                                ]
                              },
                              "status": {
                                "type": "integer",
                                "minimum": 100,
                                "maximum": 599
                              }
                            },
                            "required": [
                              "fromModel",
                              "fromRoute",
                              "toModel",
                              "toRoute",
                              "reason"
                            ],
                            "additionalProperties": false
                          },
                          "metadata": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string",
                                "enum": [
                                  "storage_full",
                                  "session_cwd_fallback",
                                  "bound_agent_root_unavailable",
                                  "relay_backlog",
                                  "runner_exited",
                                  "relay_undeliverable",
                                  "interrupt_undeliverable"
                                ]
                              }
                            },
                            "required": [
                              "code"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "level",
                          "message"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "router_switch"
                          },
                          "tier": {
                            "type": "string"
                          },
                          "route": {
                            "type": "string"
                          },
                          "fromModel": {
                            "type": "string"
                          },
                          "toModel": {
                            "type": "string"
                          },
                          "thinkingLevel": {
                            "type": "string",
                            "enum": [
                              "minimal",
                              "low",
                              "medium",
                              "high",
                              "xhigh"
                            ]
                          },
                          "trigger": {
                            "type": "string",
                            "enum": [
                              "first_turn",
                              "new_task",
                              "idle",
                              "manual_compact",
                              "overflow",
                              "modality_switch",
                              "tier_change"
                            ]
                          },
                          "rationale": {
                            "type": "string"
                          },
                          "probabilities": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {
                              "type": "number"
                            }
                          },
                          "visionFallback": {
                            "type": "boolean"
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "tier",
                          "route",
                          "fromModel",
                          "toModel",
                          "thinkingLevel",
                          "trigger",
                          "visionFallback"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "complete"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "completed",
                              "failed",
                              "cancelled"
                            ]
                          },
                          "result": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state",
                          "status"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "ask"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          },
                          "questions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "question": {
                                  "type": "string"
                                },
                                "header": {
                                  "type": "string"
                                },
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "label": {
                                        "type": "string"
                                      },
                                      "description": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "label"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "multiSelect": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "question",
                                "options"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state",
                          "questions"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "interrupted"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "sleep"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          },
                          "wakeAt": {
                            "type": "number"
                          },
                          "pollWake": {
                            "type": "boolean"
                          },
                          "quiet": {
                            "type": "boolean",
                            "const": true
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state",
                          "wakeAt"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "turn_started"
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "complete"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "completed",
                              "failed",
                              "cancelled"
                            ]
                          },
                          "result": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "ask"
                          },
                          "status": {
                            "type": "string",
                            "const": "ask"
                          },
                          "questions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "question": {
                                  "type": "string"
                                },
                                "header": {
                                  "type": "string"
                                },
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "label": {
                                        "type": "string"
                                      },
                                      "description": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "label"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "multiSelect": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "question",
                                "options"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "questions"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "interrupted"
                          },
                          "status": {
                            "type": "string",
                            "const": "interrupted"
                          },
                          "error": {
                            "type": "string"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "sleep"
                          },
                          "status": {
                            "type": "string",
                            "const": "sleep"
                          },
                          "wakeAt": {
                            "type": "number"
                          },
                          "pollWake": {
                            "type": "boolean"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "wakeAt"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "session_created"
                      },
                      "prompt": {
                        "type": "string"
                      },
                      "createdAt": {
                        "type": "string"
                      },
                      "clientRequestId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      }
                    },
                    "required": [
                      "type",
                      "prompt",
                      "createdAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "interrupt_requested"
                      },
                      "requestedAt": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "requestedAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "agent_message"
                      },
                      "message": {
                        "type": "string",
                        "minLength": 1
                      },
                      "createdAt": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "message",
                      "createdAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "view_shown"
                      },
                      "view": {
                        "type": "string"
                      },
                      "createdAt": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "view",
                      "createdAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "prompt_submitted"
                          },
                          "prompt": {
                            "type": "string"
                          },
                          "inputKind": {
                            "type": "string",
                            "enum": [
                              "initial",
                              "message"
                            ]
                          },
                          "behavior": {
                            "type": "string",
                            "enum": [
                              "steer",
                              "follow_up"
                            ]
                          },
                          "sender": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "user"
                                  },
                                  "userId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "userId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "app"
                                  },
                                  "appId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "appId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "session"
                                  },
                                  "sessionId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "sessionId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "system"
                                  }
                                },
                                "required": [
                                  "kind"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "clientRequestId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "images": {
                            "maxItems": 4,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "storageId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "mimeType": {
                                  "type": "string",
                                  "enum": [
                                    "image/png",
                                    "image/jpeg",
                                    "image/webp",
                                    "image/gif"
                                  ]
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 5242880
                                }
                              },
                              "required": [
                                "storageId",
                                "mimeType",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "attachments": {
                            "maxItems": 10,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "path": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 255
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "mimeType": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "path",
                                "name",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "dictated": {
                            "type": "boolean",
                            "const": true
                          }
                        },
                        "required": [
                          "type",
                          "prompt",
                          "inputKind",
                          "behavior",
                          "sender"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "note_submitted"
                          },
                          "note": {
                            "type": "string"
                          },
                          "sender": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "user"
                                  },
                                  "userId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "userId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "app"
                                  },
                                  "appId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "appId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "session"
                                  },
                                  "sessionId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "sessionId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "system"
                                  }
                                },
                                "required": [
                                  "kind"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "clientRequestId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "images": {
                            "maxItems": 4,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "storageId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "mimeType": {
                                  "type": "string",
                                  "enum": [
                                    "image/png",
                                    "image/jpeg",
                                    "image/webp",
                                    "image/gif"
                                  ]
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 5242880
                                }
                              },
                              "required": [
                                "storageId",
                                "mimeType",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "attachments": {
                            "maxItems": 10,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "path": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 255
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "mimeType": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "path",
                                "name",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "dictated": {
                            "type": "boolean",
                            "const": true
                          }
                        },
                        "required": [
                          "type",
                          "note",
                          "sender"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "answer_submitted"
                          },
                          "answer": {
                            "type": "string"
                          },
                          "sender": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "user"
                                  },
                                  "userId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "userId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "app"
                                  },
                                  "appId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "appId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "session"
                                  },
                                  "sessionId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "sessionId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "system"
                                  }
                                },
                                "required": [
                                  "kind"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "clientRequestId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "images": {
                            "maxItems": 4,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "storageId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "mimeType": {
                                  "type": "string",
                                  "enum": [
                                    "image/png",
                                    "image/jpeg",
                                    "image/webp",
                                    "image/gif"
                                  ]
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 5242880
                                }
                              },
                              "required": [
                                "storageId",
                                "mimeType",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "attachments": {
                            "maxItems": 10,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "path": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 255
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "mimeType": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "path",
                                "name",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "dictated": {
                            "type": "boolean",
                            "const": true
                          }
                        },
                        "required": [
                          "type",
                          "answer",
                          "sender"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  }
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": {}
              }
            ]
          },
          "createdAt": {
            "type": "number"
          }
        },
        "required": [
          "seq",
          "event",
          "createdAt"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "const": "no_default_session"
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false,
          "description": "The selected owner has no default session (404)"
        },
        {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "const": "not_found"
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false,
          "description": "The session is unavailable to this caller (404)"
        }
      ]
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "invalid_cursor"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "Opaque collection cursor is malformed or bound to another walk (400)"
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/agents/{agentSlug}/sessions/default/messages

Create or message an agent's default session

CLI
bento agent session default message create --agent-slug seo-specialist --prompt "..."
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "prompt": {
      "type": "string",
      "description": "The words of the input. May be empty when it carries images or attachments."
    },
    "clientRequestId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "images": {
      "maxItems": 4,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "minLength": 1
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp",
              "image/gif"
            ]
          }
        },
        "required": [
          "data",
          "mimeType"
        ]
      }
    },
    "attachments": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "mimeType": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "path",
          "name",
          "bytes"
        ]
      }
    },
    "dictated": {
      "description": "True when the words were transcribed from speech.",
      "type": "boolean"
    },
    "tier": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "behavior": {
      "default": "steer",
      "type": "string",
      "enum": [
        "steer",
        "follow_up"
      ]
    },
    "sourceSessionId": {
      "type": "string",
      "minLength": 1
    },
    "agentFirstMessage": {
      "type": "string",
      "maxLength": 2000
    }
  },
  "required": [
    "prompt"
  ],
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "session": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string"
            },
            "status": {
              "type": "string",
              "enum": [
                "running",
                "complete",
                "ask",
                "interrupted",
                "sleep"
              ]
            },
            "lastEventSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "lastDeliveredInputSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "sessionId",
            "status",
            "lastEventSeq",
            "lastDeliveredInputSeq"
          ],
          "additionalProperties": false
        },
        "snapshot": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "pinned": {
              "type": "boolean"
            },
            "pin": {
              "type": "object",
              "properties": {
                "pinned": {
                  "type": "boolean"
                },
                "version": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "pinned",
                "version"
              ],
              "additionalProperties": false
            },
            "turnStatus": {
              "type": "string",
              "enum": [
                "running",
                "complete",
                "ask",
                "interrupted",
                "sleep"
              ]
            },
            "turnError": {
              "type": "string"
            },
            "bucket": {
              "type": "string",
              "enum": [
                "asking",
                "running",
                "scheduled",
                "done"
              ]
            },
            "title": {
              "type": "string"
            },
            "titleOrigin": {
              "type": "string",
              "enum": [
                "excerpt",
                "auto",
                "manual"
              ]
            },
            "titleStatus": {
              "type": "string",
              "enum": [
                "generating",
                "complete",
                "failed"
              ]
            },
            "cwd": {
              "type": "string"
            },
            "agent": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ],
              "additionalProperties": false
            },
            "onboarding": {
              "type": "boolean"
            },
            "createdBySessionId": {
              "type": "string"
            },
            "machine": {
              "type": "object",
              "properties": {
                "definitionName": {
                  "type": "string"
                },
                "currentState": {
                  "type": "string"
                },
                "followingDefinitionState": {
                  "type": "string"
                },
                "progress": {
                  "type": "object",
                  "properties": {
                    "completed": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "total": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "completed",
                    "total"
                  ],
                  "additionalProperties": false
                },
                "orderedPath": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "index": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "name": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string"
                      },
                      "phase": {
                        "type": "string",
                        "enum": [
                          "past",
                          "current",
                          "future",
                          "outcome"
                        ]
                      },
                      "terminalStatus": {
                        "type": "string",
                        "enum": [
                          "completed",
                          "failed",
                          "cancelled",
                          "error"
                        ]
                      }
                    },
                    "required": [
                      "key",
                      "index",
                      "name",
                      "phase"
                    ],
                    "additionalProperties": false
                  }
                },
                "activity": {
                  "type": "string",
                  "enum": [
                    "running",
                    "sleeping",
                    "waiting",
                    "idle"
                  ]
                },
                "nextWakeAt": {
                  "type": "number"
                },
                "pollIntervalMs": {
                  "type": "number"
                },
                "outcome": {
                  "type": "string",
                  "enum": [
                    "interrupted",
                    "completed",
                    "failed",
                    "cancelled",
                    "error"
                  ]
                }
              },
              "required": [
                "orderedPath",
                "activity"
              ],
              "additionalProperties": false
            },
            "createdAt": {
              "type": "number"
            },
            "updatedAt": {
              "type": "number"
            },
            "lastEventSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "unread": {
              "type": "boolean"
            },
            "audience": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "workspace"
                    }
                  },
                  "required": [
                    "kind"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "specific"
                    },
                    "count": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "preview": {
                      "maxItems": 5,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "memberId": {
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "role": {
                            "type": "string",
                            "enum": [
                              "owner",
                              "editor",
                              "viewer"
                            ]
                          }
                        },
                        "required": [
                          "memberId",
                          "userId",
                          "name",
                          "email",
                          "role"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "kind",
                    "count",
                    "preview"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "archive": {
              "type": "object",
              "properties": {
                "globalArchivedAt": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "globalArchiveOrigin": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "manual",
                        "automatic"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "personalArchivedAt": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "reason": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "global",
                        "personal"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "globalArchivedAt",
                "globalArchiveOrigin",
                "personalArchivedAt",
                "reason"
              ],
              "additionalProperties": false
            },
            "permissions": {
              "type": "object",
              "properties": {
                "send": {
                  "type": "boolean"
                },
                "answer": {
                  "type": "boolean"
                },
                "interrupt": {
                  "type": "boolean"
                },
                "rename": {
                  "type": "boolean"
                },
                "pin": {
                  "type": "boolean"
                },
                "manageAudience": {
                  "type": "boolean"
                },
                "personalArchive": {
                  "type": "boolean"
                },
                "globalArchive": {
                  "type": "boolean"
                },
                "delete": {
                  "type": "boolean"
                }
              },
              "required": [
                "send",
                "answer",
                "interrupt",
                "rename",
                "pin",
                "manageAudience",
                "personalArchive",
                "globalArchive",
                "delete"
              ],
              "additionalProperties": false
            },
            "view": {
              "type": "string"
            },
            "viewRevision": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "viewBy": {
              "type": "string",
              "enum": [
                "user",
                "agent"
              ]
            },
            "workspaceId": {
              "type": "string"
            },
            "tier": {
              "type": "string",
              "enum": [
                "frontier",
                "balanced",
                "economy",
                "openai-frontier",
                "openai-max",
                "anthropic-frontier",
                "anthropic-max",
                "anthropic-balanced",
                "google-recommended",
                "google-balanced"
              ]
            },
            "lastDeliveredInputSeq": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "deliveryAttempt": {
              "type": "object",
              "properties": {
                "attemptId": {
                  "type": "string",
                  "minLength": 1
                },
                "throughSeq": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "initial_prompt",
                    "message",
                    "answer"
                  ]
                },
                "createdAt": {
                  "type": "number"
                }
              },
              "required": [
                "attemptId",
                "throughSeq",
                "kind",
                "createdAt"
              ],
              "additionalProperties": false
            },
            "todos": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "in_progress",
                      "completed",
                      "failed"
                    ]
                  }
                },
                "required": [
                  "id",
                  "content",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "followUpQueue": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string"
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "string"
                        },
                        "mimeType": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "data",
                        "mimeType"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "message"
                ],
                "additionalProperties": false
              }
            },
            "requestedMachine": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "prompt": {
                  "type": "string"
                },
                "states": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                }
              },
              "required": [
                "name",
                "prompt",
                "states"
              ],
              "additionalProperties": false
            },
            "machineState": {
              "type": "object",
              "properties": {
                "definition": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "prompt": {
                      "type": "string"
                    },
                    "states": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "name",
                    "prompt",
                    "states"
                  ],
                  "additionalProperties": false
                },
                "prompt": {
                  "type": "string"
                },
                "currentState": {
                  "type": "string"
                },
                "currentInput": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "progress": {
                  "type": "object",
                  "properties": {
                    "states": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "states"
                  ],
                  "additionalProperties": {}
                },
                "history": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "terminal": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "terminalAcknowledged": {
                  "type": "boolean"
                },
                "createdAt": {
                  "type": "number"
                },
                "updatedAt": {
                  "type": "number"
                }
              },
              "required": [
                "definition",
                "prompt",
                "history",
                "createdAt",
                "updatedAt"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "id",
            "pinned",
            "turnStatus",
            "bucket",
            "title",
            "titleOrigin",
            "titleStatus",
            "createdAt",
            "updatedAt",
            "lastEventSeq",
            "unread",
            "audience",
            "archive",
            "permissions",
            "workspaceId",
            "lastDeliveredInputSeq"
          ],
          "additionalProperties": false
        },
        "history": {
          "type": "object",
          "properties": {
            "events": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "seq": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "event": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "turn_started"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "step"
                                  },
                                  "step": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "text_delta"
                                          },
                                          "delta": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "delta"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "reasoning_delta"
                                          },
                                          "delta": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "delta"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "text"
                                          },
                                          "text": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "text"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "reasoning"
                                          },
                                          "text": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "text"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "tool_call_start"
                                          },
                                          "toolName": {
                                            "type": "string"
                                          },
                                          "toolCallId": {
                                            "type": "string"
                                          },
                                          "input": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "toolName",
                                          "toolCallId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "tool_call"
                                          },
                                          "toolName": {
                                            "type": "string"
                                          },
                                          "toolCallId": {
                                            "type": "string"
                                          },
                                          "input": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "isError": {
                                            "type": "boolean"
                                          },
                                          "output": {
                                            "type": "array",
                                            "items": {
                                              "oneOf": [
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "const": "text"
                                                    },
                                                    "text": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "type",
                                                    "text"
                                                  ],
                                                  "additionalProperties": false
                                                },
                                                {
                                                  "type": "object",
                                                  "properties": {
                                                    "type": {
                                                      "type": "string",
                                                      "const": "image"
                                                    },
                                                    "data": {
                                                      "type": "string"
                                                    },
                                                    "mimeType": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "type",
                                                    "data",
                                                    "mimeType"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              ]
                                            }
                                          },
                                          "details": {}
                                        },
                                        "required": [
                                          "type",
                                          "toolName",
                                          "toolCallId",
                                          "isError"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "system"
                                          },
                                          "message": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "step"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "task_started"
                                  },
                                  "task": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "task"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "task_output"
                                  },
                                  "taskId": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "chunk": {
                                    "type": "string"
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "taskId",
                                  "chunk"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "task_settled"
                                  },
                                  "settlement": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "pattern": "^t\\d+$"
                                          },
                                          "status": {
                                            "type": "string",
                                            "const": "completed"
                                          },
                                          "settledAt": {
                                            "type": "number"
                                          },
                                          "result": {}
                                        },
                                        "required": [
                                          "id",
                                          "status",
                                          "settledAt",
                                          "result"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "pattern": "^t\\d+$"
                                          },
                                          "status": {
                                            "type": "string",
                                            "const": "failed"
                                          },
                                          "settledAt": {
                                            "type": "number"
                                          },
                                          "error": {}
                                        },
                                        "required": [
                                          "id",
                                          "status",
                                          "settledAt",
                                          "error"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "pattern": "^t\\d+$"
                                          },
                                          "status": {
                                            "type": "string",
                                            "const": "stopped"
                                          },
                                          "settledAt": {
                                            "type": "number"
                                          },
                                          "reason": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "id",
                                          "status",
                                          "settledAt",
                                          "reason"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string",
                                            "pattern": "^t\\d+$"
                                          },
                                          "status": {
                                            "type": "string",
                                            "const": "lost"
                                          },
                                          "settledAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "id",
                                          "status",
                                          "settledAt"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "settlement"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "heartbeat"
                                  },
                                  "timestamp": {
                                    "type": "number"
                                  },
                                  "activeTaskIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "timestamp",
                                  "activeTaskIds"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "todos"
                                  },
                                  "todos": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "content": {
                                          "type": "string"
                                        },
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "pending",
                                            "in_progress",
                                            "completed",
                                            "failed"
                                          ]
                                        }
                                      },
                                      "required": [
                                        "id",
                                        "content",
                                        "status"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "todos"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "follow_up_queue"
                                  },
                                  "followUpQueue": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "message"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "followUpQueue"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "state_machine"
                                  },
                                  "stateMachine": {
                                    "type": "object",
                                    "properties": {
                                      "definition": {
                                        "type": "object",
                                        "properties": {
                                          "name": {
                                            "type": "string"
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "states": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "name",
                                          "prompt",
                                          "states"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "currentState": {
                                        "type": "string"
                                      },
                                      "currentInput": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "progress": {
                                        "type": "object",
                                        "properties": {
                                          "states": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "states"
                                        ],
                                        "additionalProperties": {}
                                      },
                                      "history": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      },
                                      "terminal": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "terminalAcknowledged": {
                                        "type": "boolean"
                                      },
                                      "createdAt": {
                                        "type": "number"
                                      },
                                      "updatedAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "definition",
                                      "prompt",
                                      "history",
                                      "createdAt",
                                      "updatedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "stateMachine"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "memory"
                                  },
                                  "phase": {
                                    "type": "string",
                                    "enum": [
                                      "observation",
                                      "reflection"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "completed"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "observations": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "usageBumpedObservations": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "phase",
                                  "status",
                                  "message"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "usage"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "turnUsage",
                                  "usageByModel",
                                  "lastMessageUsage",
                                  "effectiveContextWindow",
                                  "contextWindowUsage"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "system"
                                  },
                                  "level": {
                                    "type": "string",
                                    "enum": [
                                      "debug",
                                      "info",
                                      "warn",
                                      "error"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "providerRecovery": {
                                    "type": "object",
                                    "properties": {
                                      "fromModel": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 256
                                      },
                                      "fromRoute": {
                                        "type": "string",
                                        "enum": [
                                          "configured",
                                          "vercel",
                                          "unknown"
                                        ]
                                      },
                                      "toModel": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 256
                                      },
                                      "toRoute": {
                                        "type": "string",
                                        "const": "vercel"
                                      },
                                      "reason": {
                                        "type": "string",
                                        "enum": [
                                          "empty_response",
                                          "provider_error"
                                        ]
                                      },
                                      "status": {
                                        "type": "integer",
                                        "minimum": 100,
                                        "maximum": 599
                                      }
                                    },
                                    "required": [
                                      "fromModel",
                                      "fromRoute",
                                      "toModel",
                                      "toRoute",
                                      "reason"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "metadata": {
                                    "type": "object",
                                    "properties": {
                                      "code": {
                                        "type": "string",
                                        "enum": [
                                          "storage_full",
                                          "session_cwd_fallback",
                                          "bound_agent_root_unavailable",
                                          "relay_backlog",
                                          "runner_exited",
                                          "relay_undeliverable",
                                          "interrupt_undeliverable"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "code"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "level",
                                  "message"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "router_switch"
                                  },
                                  "tier": {
                                    "type": "string"
                                  },
                                  "route": {
                                    "type": "string"
                                  },
                                  "fromModel": {
                                    "type": "string"
                                  },
                                  "toModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  },
                                  "trigger": {
                                    "type": "string",
                                    "enum": [
                                      "first_turn",
                                      "new_task",
                                      "idle",
                                      "manual_compact",
                                      "overflow",
                                      "modality_switch",
                                      "tier_change"
                                    ]
                                  },
                                  "rationale": {
                                    "type": "string"
                                  },
                                  "probabilities": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "number"
                                    }
                                  },
                                  "visionFallback": {
                                    "type": "boolean"
                                  },
                                  "origin": {
                                    "type": "object",
                                    "properties": {
                                      "taskId": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      }
                                    },
                                    "required": [
                                      "taskId"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "tier",
                                  "route",
                                  "fromModel",
                                  "toModel",
                                  "thinkingLevel",
                                  "trigger",
                                  "visionFallback"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "complete"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "result": {
                                    "type": "string"
                                  },
                                  "error": {
                                    "type": "string"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state",
                                  "status"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "ask"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state",
                                  "questions"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "interrupted"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "sleep"
                                  },
                                  "state": {
                                    "type": "object",
                                    "properties": {
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "waiting_for_human",
                                          "sleeping",
                                          "interrupted",
                                          "completed",
                                          "failed",
                                          "cancelled"
                                        ]
                                      },
                                      "mode": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "const": "agent"
                                          },
                                          {
                                            "type": "string",
                                            "const": "auto"
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      },
                                      "options": {
                                        "type": "object",
                                        "properties": {
                                          "model": {
                                            "type": "string"
                                          },
                                          "memoryModel": {
                                            "type": "string"
                                          },
                                          "thinkingLevel": {
                                            "type": "string",
                                            "enum": [
                                              "minimal",
                                              "low",
                                              "medium",
                                              "high",
                                              "xhigh"
                                            ]
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "agent": {
                                        "type": "object",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "running",
                                              "waiting",
                                              "completed",
                                              "failed",
                                              "cancelled"
                                            ]
                                          },
                                          "messages": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "role": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "role"
                                              ],
                                              "additionalProperties": {}
                                            }
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "messages"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "stateMachine": {
                                        "type": "object",
                                        "properties": {
                                          "definition": {
                                            "type": "object",
                                            "properties": {
                                              "name": {
                                                "type": "string"
                                              },
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "states": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "name",
                                              "prompt",
                                              "states"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "prompt": {
                                            "type": "string"
                                          },
                                          "currentState": {
                                            "type": "string"
                                          },
                                          "currentInput": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "progress": {
                                            "type": "object",
                                            "properties": {
                                              "states": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {}
                                                }
                                              }
                                            },
                                            "required": [
                                              "states"
                                            ],
                                            "additionalProperties": {}
                                          },
                                          "history": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            }
                                          },
                                          "terminal": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          },
                                          "terminalAcknowledged": {
                                            "type": "boolean"
                                          },
                                          "createdAt": {
                                            "type": "number"
                                          },
                                          "updatedAt": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "definition",
                                          "prompt",
                                          "history",
                                          "createdAt",
                                          "updatedAt"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "pendingStateTransition": {
                                        "type": "object",
                                        "properties": {
                                          "stateName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "stateName"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "todos": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "content": {
                                              "type": "string"
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "pending",
                                                "in_progress",
                                                "completed",
                                                "failed"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "content",
                                            "status"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "followUpQueue": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "message": {
                                              "type": "string"
                                            },
                                            "images": {
                                              "type": "array",
                                              "items": {
                                                "type": "object",
                                                "properties": {
                                                  "data": {
                                                    "type": "string"
                                                  },
                                                  "mimeType": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": [
                                                  "data",
                                                  "mimeType"
                                                ],
                                                "additionalProperties": false
                                              }
                                            }
                                          },
                                          "required": [
                                            "message"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "queuedCommands": {
                                        "type": "array",
                                        "items": {
                                          "oneOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "prompt"
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "message",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "answer"
                                                },
                                                "questions": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "question": {
                                                        "type": "string"
                                                      },
                                                      "header": {
                                                        "type": "string"
                                                      },
                                                      "options": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "label": {
                                                              "type": "string"
                                                            },
                                                            "description": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": [
                                                            "label"
                                                          ],
                                                          "additionalProperties": false
                                                        }
                                                      },
                                                      "multiSelect": {
                                                        "type": "boolean"
                                                      }
                                                    },
                                                    "required": [
                                                      "question",
                                                      "options"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "answers": {
                                                  "type": "object",
                                                  "propertyNames": {
                                                    "type": "string"
                                                  },
                                                  "additionalProperties": {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  }
                                                },
                                                "behavior": {
                                                  "type": "string",
                                                  "enum": [
                                                    "steer",
                                                    "follow_up"
                                                  ]
                                                },
                                                "message": {
                                                  "type": "string"
                                                },
                                                "images": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "data": {
                                                        "type": "string"
                                                      },
                                                      "mimeType": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "data",
                                                      "mimeType"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": [
                                                "type",
                                                "questions",
                                                "answers",
                                                "behavior"
                                              ],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "type": {
                                                  "type": "string",
                                                  "const": "wake"
                                                }
                                              },
                                              "required": [
                                                "type"
                                              ],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      },
                                      "tasks": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string",
                                              "pattern": "^t\\d+$"
                                            },
                                            "kind": {
                                              "type": "string",
                                              "enum": [
                                                "tool",
                                                "subagent",
                                                "scheduled"
                                              ]
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            },
                                            "ownerScopeId": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "pattern": "^turn-\\d+$"
                                                },
                                                {
                                                  "type": "string",
                                                  "pattern": "^task:t\\d+$"
                                                }
                                              ]
                                            },
                                            "status": {
                                              "type": "string",
                                              "enum": [
                                                "running",
                                                "scheduled",
                                                "completed",
                                                "failed",
                                                "stopped",
                                                "lost"
                                              ]
                                            },
                                            "startedAt": {
                                              "type": "number"
                                            },
                                            "wakeAt": {
                                              "type": "number"
                                            }
                                          },
                                          "required": [
                                            "id",
                                            "kind",
                                            "name",
                                            "label",
                                            "ownerScopeId",
                                            "status",
                                            "startedAt"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "taskOutputTails": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        },
                                        "additionalProperties": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      },
                                      "pendingLostTaskReminderTaskIds": {
                                        "type": "array",
                                        "items": {
                                          "type": "string",
                                          "pattern": "^t\\d+$"
                                        }
                                      },
                                      "nextTaskId": {
                                        "type": "number"
                                      },
                                      "wireGuardHorizon": {
                                        "type": "object",
                                        "properties": {
                                          "evictionHorizon": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "evictionHorizon"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "routing": {
                                        "type": "object",
                                        "properties": {
                                          "saved": {
                                            "type": "object",
                                            "properties": {
                                              "tier": {
                                                "type": "string"
                                              },
                                              "route": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "tier",
                                              "route"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "compactedSinceLastMessage": {
                                            "type": "boolean"
                                          },
                                          "currentTask": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "status",
                                      "mode",
                                      "agent"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "wakeAt": {
                                    "type": "number"
                                  },
                                  "pollWake": {
                                    "type": "boolean"
                                  },
                                  "quiet": {
                                    "type": "boolean",
                                    "const": true
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "state",
                                  "wakeAt"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "turn_started"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "complete"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "result": {
                                    "type": "string"
                                  },
                                  "error": {
                                    "type": "string"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "ask"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "ask"
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "questions"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "interrupted"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "interrupted"
                                  },
                                  "error": {
                                    "type": "string"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "sleep"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "sleep"
                                  },
                                  "wakeAt": {
                                    "type": "number"
                                  },
                                  "pollWake": {
                                    "type": "boolean"
                                  },
                                  "turnUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usageByModel": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "model": {
                                          "type": "string"
                                        },
                                        "transport": {
                                          "type": "object",
                                          "properties": {
                                            "provider": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "duet-gateway",
                                                    "vercel-ai-gateway",
                                                    "openrouter"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "openai-codex",
                                                    "github-copilot"
                                                  ]
                                                }
                                              ]
                                            },
                                            "billing": {
                                              "type": "string",
                                              "enum": [
                                                "plan-covered",
                                                "metered"
                                              ]
                                            }
                                          },
                                          "required": [
                                            "provider",
                                            "billing"
                                          ],
                                          "additionalProperties": false
                                        },
                                        "usage": {
                                          "type": "object",
                                          "properties": {
                                            "input": {
                                              "type": "number"
                                            },
                                            "output": {
                                              "type": "number"
                                            },
                                            "cacheRead": {
                                              "type": "number"
                                            },
                                            "cacheWrite": {
                                              "type": "number"
                                            },
                                            "cacheWrite1h": {
                                              "type": "number"
                                            },
                                            "totalTokens": {
                                              "type": "number"
                                            },
                                            "cost": {
                                              "type": "object",
                                              "properties": {
                                                "input": {
                                                  "type": "number"
                                                },
                                                "output": {
                                                  "type": "number"
                                                },
                                                "cacheRead": {
                                                  "type": "number"
                                                },
                                                "cacheWrite": {
                                                  "type": "number"
                                                },
                                                "total": {
                                                  "type": "number"
                                                }
                                              },
                                              "required": [
                                                "input",
                                                "output",
                                                "cacheRead",
                                                "cacheWrite",
                                                "total"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "required": [
                                            "input",
                                            "output",
                                            "cacheRead",
                                            "cacheWrite",
                                            "totalTokens",
                                            "cost"
                                          ],
                                          "additionalProperties": false
                                        }
                                      },
                                      "required": [
                                        "model",
                                        "transport",
                                        "usage"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "lastMessageUsage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "effectiveContextWindow": {
                                    "type": "number"
                                  },
                                  "contextWindowUsage": {
                                    "type": "object",
                                    "properties": {
                                      "systemPrompt": {
                                        "type": "number"
                                      },
                                      "messages": {
                                        "type": "number"
                                      },
                                      "localMemory": {
                                        "type": "number"
                                      },
                                      "globalMemory": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "systemPrompt",
                                      "messages",
                                      "localMemory",
                                      "globalMemory"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "type",
                                  "wakeAt"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "session_created"
                              },
                              "prompt": {
                                "type": "string"
                              },
                              "createdAt": {
                                "type": "string"
                              },
                              "clientRequestId": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                              }
                            },
                            "required": [
                              "type",
                              "prompt",
                              "createdAt"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "interrupt_requested"
                              },
                              "requestedAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "requestedAt"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "agent_message"
                              },
                              "message": {
                                "type": "string",
                                "minLength": 1
                              },
                              "createdAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "message",
                              "createdAt"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "view_shown"
                              },
                              "view": {
                                "type": "string"
                              },
                              "createdAt": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "view",
                              "createdAt"
                            ],
                            "additionalProperties": false
                          },
                          {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "prompt_submitted"
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "inputKind": {
                                    "type": "string",
                                    "enum": [
                                      "initial",
                                      "message"
                                    ]
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "sender": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "user"
                                          },
                                          "userId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "userId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "app"
                                          },
                                          "appId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "appId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "session"
                                          },
                                          "sessionId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "sessionId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "system"
                                          }
                                        },
                                        "required": [
                                          "kind"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "clientRequestId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                  },
                                  "images": {
                                    "maxItems": 4,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "storageId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "enum": [
                                            "image/png",
                                            "image/jpeg",
                                            "image/webp",
                                            "image/gif"
                                          ]
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 5242880
                                        }
                                      },
                                      "required": [
                                        "storageId",
                                        "mimeType",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "attachments": {
                                    "maxItems": 10,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "path": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "name": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 255
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 9007199254740991
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "required": [
                                        "path",
                                        "name",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "dictated": {
                                    "type": "boolean",
                                    "const": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "prompt",
                                  "inputKind",
                                  "behavior",
                                  "sender"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "note_submitted"
                                  },
                                  "note": {
                                    "type": "string"
                                  },
                                  "sender": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "user"
                                          },
                                          "userId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "userId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "app"
                                          },
                                          "appId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "appId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "session"
                                          },
                                          "sessionId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "sessionId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "system"
                                          }
                                        },
                                        "required": [
                                          "kind"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "clientRequestId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                  },
                                  "images": {
                                    "maxItems": 4,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "storageId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "enum": [
                                            "image/png",
                                            "image/jpeg",
                                            "image/webp",
                                            "image/gif"
                                          ]
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 5242880
                                        }
                                      },
                                      "required": [
                                        "storageId",
                                        "mimeType",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "attachments": {
                                    "maxItems": 10,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "path": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "name": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 255
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 9007199254740991
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "required": [
                                        "path",
                                        "name",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "dictated": {
                                    "type": "boolean",
                                    "const": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "note",
                                  "sender"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "answer_submitted"
                                  },
                                  "answer": {
                                    "type": "string"
                                  },
                                  "sender": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "user"
                                          },
                                          "userId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "userId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "app"
                                          },
                                          "appId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "appId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "session"
                                          },
                                          "sessionId": {
                                            "type": "string",
                                            "minLength": 1
                                          }
                                        },
                                        "required": [
                                          "kind",
                                          "sessionId"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "kind": {
                                            "type": "string",
                                            "const": "system"
                                          }
                                        },
                                        "required": [
                                          "kind"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  },
                                  "clientRequestId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                  },
                                  "images": {
                                    "maxItems": 4,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "storageId": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "enum": [
                                            "image/png",
                                            "image/jpeg",
                                            "image/webp",
                                            "image/gif"
                                          ]
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 5242880
                                        }
                                      },
                                      "required": [
                                        "storageId",
                                        "mimeType",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "attachments": {
                                    "maxItems": 10,
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "path": {
                                          "type": "string",
                                          "minLength": 1
                                        },
                                        "name": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 255
                                        },
                                        "bytes": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 9007199254740991
                                        },
                                        "mimeType": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "required": [
                                        "path",
                                        "name",
                                        "bytes"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "dictated": {
                                    "type": "boolean",
                                    "const": true
                                  }
                                },
                                "required": [
                                  "type",
                                  "answer",
                                  "sender"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": {}
                      }
                    ]
                  },
                  "createdAt": {
                    "type": "number"
                  }
                },
                "required": [
                  "seq",
                  "event",
                  "createdAt"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "events"
          ],
          "additionalProperties": false
        },
        "dispatched": {
          "type": "boolean",
          "const": false
        },
        "delivery": {
          "type": "string",
          "enum": [
            "accepted",
            "queued"
          ]
        }
      },
      "required": [
        "url",
        "session",
        "snapshot",
        "history",
        "dispatched",
        "delivery"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "ok": {
          "type": "boolean",
          "const": true
        },
        "delivery": {
          "type": "string",
          "enum": [
            "accepted",
            "queued"
          ]
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "sessionId": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "ok",
        "delivery",
        "url",
        "sessionId"
      ],
      "additionalProperties": false
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/agents/{agentSlug}/sessions/default/messages/wait

Create or message an agent's default session and wait for the turn

CLI
bento agent session default message create --agent-slug seo-specialist --prompt "..."
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "prompt": {
      "type": "string",
      "description": "The words of the input. May be empty when it carries images or attachments."
    },
    "clientRequestId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "images": {
      "maxItems": 4,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "minLength": 1
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp",
              "image/gif"
            ]
          }
        },
        "required": [
          "data",
          "mimeType"
        ]
      }
    },
    "attachments": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "mimeType": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "path",
          "name",
          "bytes"
        ]
      }
    },
    "dictated": {
      "description": "True when the words were transcribed from speech.",
      "type": "boolean"
    },
    "tier": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "behavior": {
      "default": "steer",
      "type": "string",
      "enum": [
        "steer",
        "follow_up"
      ]
    },
    "sourceSessionId": {
      "type": "string",
      "minLength": 1
    },
    "agentFirstMessage": {
      "type": "string",
      "maxLength": 2000
    }
  },
  "required": [
    "prompt",
    "clientRequestId"
  ],
  "additionalProperties": false
}
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "waitMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 720000
    }
  }
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "cwd": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
        },
        "terminal": {
          "type": "object",
          "properties": {
            "seq": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "event": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "step"
                            },
                            "step": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call_start"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "isError": {
                                      "type": "boolean"
                                    },
                                    "output": {
                                      "type": "array",
                                      "items": {
                                        "oneOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "text"
                                              },
                                              "text": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "text"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "image"
                                              },
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "details": {}
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId",
                                    "isError"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "system"
                                    },
                                    "message": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "step"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_started"
                            },
                            "task": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "tool",
                                    "subagent",
                                    "scheduled"
                                  ]
                                },
                                "name": {
                                  "type": "string"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "ownerScopeId": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "pattern": "^turn-\\d+$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^task:t\\d+$"
                                    }
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "scheduled",
                                    "completed",
                                    "failed",
                                    "stopped",
                                    "lost"
                                  ]
                                },
                                "startedAt": {
                                  "type": "number"
                                },
                                "wakeAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "id",
                                "kind",
                                "name",
                                "label",
                                "ownerScopeId",
                                "status",
                                "startedAt"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "task"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_output"
                            },
                            "taskId": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "chunk": {
                              "type": "string"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "taskId",
                            "chunk"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_settled"
                            },
                            "settlement": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "completed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "result": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "result"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "failed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "error": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "error"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "stopped"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "reason": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "reason"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "lost"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "settlement"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "heartbeat"
                            },
                            "timestamp": {
                              "type": "number"
                            },
                            "activeTaskIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            }
                          },
                          "required": [
                            "type",
                            "timestamp",
                            "activeTaskIds"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "todos"
                            },
                            "todos": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "in_progress",
                                      "completed",
                                      "failed"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "content",
                                  "status"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "todos"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "follow_up_queue"
                            },
                            "followUpQueue": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "message"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "followUpQueue"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "state_machine"
                            },
                            "stateMachine": {
                              "type": "object",
                              "properties": {
                                "definition": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "states": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "prompt",
                                    "states"
                                  ],
                                  "additionalProperties": false
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "currentState": {
                                  "type": "string"
                                },
                                "currentInput": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "progress": {
                                  "type": "object",
                                  "properties": {
                                    "states": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "states"
                                  ],
                                  "additionalProperties": {}
                                },
                                "history": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "terminal": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "terminalAcknowledged": {
                                  "type": "boolean"
                                },
                                "createdAt": {
                                  "type": "number"
                                },
                                "updatedAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "definition",
                                "prompt",
                                "history",
                                "createdAt",
                                "updatedAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "stateMachine"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "memory"
                            },
                            "phase": {
                              "type": "string",
                              "enum": [
                                "observation",
                                "reflection"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "completed"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "observations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "usageBumpedObservations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "type",
                            "phase",
                            "status",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "usage"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "turnUsage",
                            "usageByModel",
                            "lastMessageUsage",
                            "effectiveContextWindow",
                            "contextWindowUsage"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "system"
                            },
                            "level": {
                              "type": "string",
                              "enum": [
                                "debug",
                                "info",
                                "warn",
                                "error"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "providerRecovery": {
                              "type": "object",
                              "properties": {
                                "fromModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "fromRoute": {
                                  "type": "string",
                                  "enum": [
                                    "configured",
                                    "vercel",
                                    "unknown"
                                  ]
                                },
                                "toModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "toRoute": {
                                  "type": "string",
                                  "const": "vercel"
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "empty_response",
                                    "provider_error"
                                  ]
                                },
                                "status": {
                                  "type": "integer",
                                  "minimum": 100,
                                  "maximum": 599
                                }
                              },
                              "required": [
                                "fromModel",
                                "fromRoute",
                                "toModel",
                                "toRoute",
                                "reason"
                              ],
                              "additionalProperties": false
                            },
                            "metadata": {
                              "type": "object",
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "enum": [
                                    "storage_full",
                                    "session_cwd_fallback",
                                    "bound_agent_root_unavailable",
                                    "relay_backlog",
                                    "runner_exited",
                                    "relay_undeliverable",
                                    "interrupt_undeliverable"
                                  ]
                                }
                              },
                              "required": [
                                "code"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "level",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "router_switch"
                            },
                            "tier": {
                              "type": "string"
                            },
                            "route": {
                              "type": "string"
                            },
                            "fromModel": {
                              "type": "string"
                            },
                            "toModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            },
                            "trigger": {
                              "type": "string",
                              "enum": [
                                "first_turn",
                                "new_task",
                                "idle",
                                "manual_compact",
                                "overflow",
                                "modality_switch",
                                "tier_change"
                              ]
                            },
                            "rationale": {
                              "type": "string"
                            },
                            "probabilities": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "visionFallback": {
                              "type": "boolean"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "tier",
                            "route",
                            "fromModel",
                            "toModel",
                            "thinkingLevel",
                            "trigger",
                            "visionFallback"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "status"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "quiet": {
                              "type": "boolean",
                              "const": true
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "status": {
                              "type": "string",
                              "const": "ask"
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "status": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "status": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "session_created"
                        },
                        "prompt": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "clientRequestId": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "required": [
                        "type",
                        "prompt",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "interrupt_requested"
                        },
                        "requestedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "requestedAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "agent_message"
                        },
                        "message": {
                          "type": "string",
                          "minLength": 1
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "view_shown"
                        },
                        "view": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "view",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "prompt_submitted"
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "inputKind": {
                              "type": "string",
                              "enum": [
                                "initial",
                                "message"
                              ]
                            },
                            "behavior": {
                              "type": "string",
                              "enum": [
                                "steer",
                                "follow_up"
                              ]
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "prompt",
                            "inputKind",
                            "behavior",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "note_submitted"
                            },
                            "note": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "note",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "answer_submitted"
                            },
                            "answer": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "answer",
                            "sender"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    }
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": {}
                }
              ]
            },
            "createdAt": {
              "type": "number"
            }
          },
          "required": [
            "seq",
            "event",
            "createdAt"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "sessionId",
        "inputSeq",
        "url",
        "terminal"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "status": {
          "type": "string",
          "const": "running"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [
        "sessionId",
        "inputSeq",
        "status",
        "url"
      ],
      "additionalProperties": false
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/audience

Page the current members of a specific session audience

CLI
bento session audience get --session-id example
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "memberId": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email",
            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "editor",
              "viewer"
            ]
          }
        },
        "required": [
          "memberId",
          "userId",
          "name",
          "email",
          "role"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "const": "not_found"
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false,
          "description": "The session is unavailable to this caller (404)"
        },
        {
          "type": "object",
          "properties": {
            "error": {
              "type": "string",
              "const": "audience_kind_immutable"
            }
          },
          "required": [
            "error"
          ],
          "additionalProperties": false,
          "description": "This session does not have a specific-people audience (409)"
        }
      ]
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "invalid_cursor"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "Opaque collection cursor is malformed or bound to another walk (400)"
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
PATCH/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/audience

Atomically update a specific session audience; self-removal returns no body when access is lost

CLI
bento session audience update --session-id example --body-file request.json
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "add": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "remove": {
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "additionalProperties": false
}
Response
  • 200
    200 response JSON schema
    {
      "$schema": "https://json-schema.org/draft/2020-12/schema",
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "pinned": {
          "type": "boolean"
        },
        "pin": {
          "type": "object",
          "properties": {
            "pinned": {
              "type": "boolean"
            },
            "version": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "pinned",
            "version"
          ],
          "additionalProperties": false
        },
        "turnStatus": {
          "type": "string",
          "enum": [
            "running",
            "complete",
            "ask",
            "interrupted",
            "sleep"
          ]
        },
        "turnError": {
          "type": "string"
        },
        "bucket": {
          "type": "string",
          "enum": [
            "asking",
            "running",
            "scheduled",
            "done"
          ]
        },
        "title": {
          "type": "string"
        },
        "titleOrigin": {
          "type": "string",
          "enum": [
            "excerpt",
            "auto",
            "manual"
          ]
        },
        "titleStatus": {
          "type": "string",
          "enum": [
            "generating",
            "complete",
            "failed"
          ]
        },
        "cwd": {
          "type": "string"
        },
        "agent": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "slug": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "name"
          ],
          "additionalProperties": false
        },
        "onboarding": {
          "type": "boolean"
        },
        "createdBySessionId": {
          "type": "string"
        },
        "machine": {
          "type": "object",
          "properties": {
            "definitionName": {
              "type": "string"
            },
            "currentState": {
              "type": "string"
            },
            "followingDefinitionState": {
              "type": "string"
            },
            "progress": {
              "type": "object",
              "properties": {
                "completed": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "total": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "completed",
                "total"
              ],
              "additionalProperties": false
            },
            "orderedPath": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "index": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "name": {
                    "type": "string"
                  },
                  "kind": {
                    "type": "string"
                  },
                  "phase": {
                    "type": "string",
                    "enum": [
                      "past",
                      "current",
                      "future",
                      "outcome"
                    ]
                  },
                  "terminalStatus": {
                    "type": "string",
                    "enum": [
                      "completed",
                      "failed",
                      "cancelled",
                      "error"
                    ]
                  }
                },
                "required": [
                  "key",
                  "index",
                  "name",
                  "phase"
                ],
                "additionalProperties": false
              }
            },
            "activity": {
              "type": "string",
              "enum": [
                "running",
                "sleeping",
                "waiting",
                "idle"
              ]
            },
            "nextWakeAt": {
              "type": "number"
            },
            "pollIntervalMs": {
              "type": "number"
            },
            "outcome": {
              "type": "string",
              "enum": [
                "interrupted",
                "completed",
                "failed",
                "cancelled",
                "error"
              ]
            }
          },
          "required": [
            "orderedPath",
            "activity"
          ],
          "additionalProperties": false
        },
        "createdAt": {
          "type": "number"
        },
        "updatedAt": {
          "type": "number"
        },
        "lastEventSeq": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "unread": {
          "type": "boolean"
        },
        "audience": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "workspace"
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "specific"
                },
                "count": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "preview": {
                  "maxItems": 5,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "memberId": {
                        "type": "string"
                      },
                      "userId": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      "role": {
                        "type": "string",
                        "enum": [
                          "owner",
                          "editor",
                          "viewer"
                        ]
                      }
                    },
                    "required": [
                      "memberId",
                      "userId",
                      "name",
                      "email",
                      "role"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "kind",
                "count",
                "preview"
              ],
              "additionalProperties": false
            }
          ]
        },
        "archive": {
          "type": "object",
          "properties": {
            "globalArchivedAt": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "globalArchiveOrigin": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "manual",
                    "automatic"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "personalArchivedAt": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            },
            "reason": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "global",
                    "personal"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "globalArchivedAt",
            "globalArchiveOrigin",
            "personalArchivedAt",
            "reason"
          ],
          "additionalProperties": false
        },
        "permissions": {
          "type": "object",
          "properties": {
            "send": {
              "type": "boolean"
            },
            "answer": {
              "type": "boolean"
            },
            "interrupt": {
              "type": "boolean"
            },
            "rename": {
              "type": "boolean"
            },
            "pin": {
              "type": "boolean"
            },
            "manageAudience": {
              "type": "boolean"
            },
            "personalArchive": {
              "type": "boolean"
            },
            "globalArchive": {
              "type": "boolean"
            },
            "delete": {
              "type": "boolean"
            }
          },
          "required": [
            "send",
            "answer",
            "interrupt",
            "rename",
            "pin",
            "manageAudience",
            "personalArchive",
            "globalArchive",
            "delete"
          ],
          "additionalProperties": false
        },
        "view": {
          "type": "string"
        },
        "viewRevision": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "viewBy": {
          "type": "string",
          "enum": [
            "user",
            "agent"
          ]
        }
      },
      "required": [
        "id",
        "pinned",
        "turnStatus",
        "bucket",
        "title",
        "titleOrigin",
        "titleStatus",
        "createdAt",
        "updatedAt",
        "lastEventSeq",
        "unread",
        "audience",
        "archive",
        "permissions"
      ],
      "additionalProperties": false
    }
  • 204 No structured response body
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/results/{seq}

Read or wait for the durable outcome of an existing session input

CLI
bento session result get --session-id example --seq 1
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "waitMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 720000
    }
  }
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "cwd": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
        },
        "terminal": {
          "type": "object",
          "properties": {
            "seq": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "event": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "step"
                            },
                            "step": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call_start"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "isError": {
                                      "type": "boolean"
                                    },
                                    "output": {
                                      "type": "array",
                                      "items": {
                                        "oneOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "text"
                                              },
                                              "text": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "text"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "image"
                                              },
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "details": {}
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId",
                                    "isError"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "system"
                                    },
                                    "message": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "step"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_started"
                            },
                            "task": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "tool",
                                    "subagent",
                                    "scheduled"
                                  ]
                                },
                                "name": {
                                  "type": "string"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "ownerScopeId": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "pattern": "^turn-\\d+$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^task:t\\d+$"
                                    }
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "scheduled",
                                    "completed",
                                    "failed",
                                    "stopped",
                                    "lost"
                                  ]
                                },
                                "startedAt": {
                                  "type": "number"
                                },
                                "wakeAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "id",
                                "kind",
                                "name",
                                "label",
                                "ownerScopeId",
                                "status",
                                "startedAt"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "task"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_output"
                            },
                            "taskId": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "chunk": {
                              "type": "string"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "taskId",
                            "chunk"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_settled"
                            },
                            "settlement": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "completed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "result": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "result"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "failed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "error": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "error"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "stopped"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "reason": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "reason"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "lost"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "settlement"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "heartbeat"
                            },
                            "timestamp": {
                              "type": "number"
                            },
                            "activeTaskIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            }
                          },
                          "required": [
                            "type",
                            "timestamp",
                            "activeTaskIds"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "todos"
                            },
                            "todos": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "in_progress",
                                      "completed",
                                      "failed"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "content",
                                  "status"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "todos"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "follow_up_queue"
                            },
                            "followUpQueue": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "message"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "followUpQueue"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "state_machine"
                            },
                            "stateMachine": {
                              "type": "object",
                              "properties": {
                                "definition": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "states": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "prompt",
                                    "states"
                                  ],
                                  "additionalProperties": false
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "currentState": {
                                  "type": "string"
                                },
                                "currentInput": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "progress": {
                                  "type": "object",
                                  "properties": {
                                    "states": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "states"
                                  ],
                                  "additionalProperties": {}
                                },
                                "history": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "terminal": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "terminalAcknowledged": {
                                  "type": "boolean"
                                },
                                "createdAt": {
                                  "type": "number"
                                },
                                "updatedAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "definition",
                                "prompt",
                                "history",
                                "createdAt",
                                "updatedAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "stateMachine"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "memory"
                            },
                            "phase": {
                              "type": "string",
                              "enum": [
                                "observation",
                                "reflection"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "completed"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "observations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "usageBumpedObservations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "type",
                            "phase",
                            "status",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "usage"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "turnUsage",
                            "usageByModel",
                            "lastMessageUsage",
                            "effectiveContextWindow",
                            "contextWindowUsage"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "system"
                            },
                            "level": {
                              "type": "string",
                              "enum": [
                                "debug",
                                "info",
                                "warn",
                                "error"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "providerRecovery": {
                              "type": "object",
                              "properties": {
                                "fromModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "fromRoute": {
                                  "type": "string",
                                  "enum": [
                                    "configured",
                                    "vercel",
                                    "unknown"
                                  ]
                                },
                                "toModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "toRoute": {
                                  "type": "string",
                                  "const": "vercel"
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "empty_response",
                                    "provider_error"
                                  ]
                                },
                                "status": {
                                  "type": "integer",
                                  "minimum": 100,
                                  "maximum": 599
                                }
                              },
                              "required": [
                                "fromModel",
                                "fromRoute",
                                "toModel",
                                "toRoute",
                                "reason"
                              ],
                              "additionalProperties": false
                            },
                            "metadata": {
                              "type": "object",
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "enum": [
                                    "storage_full",
                                    "session_cwd_fallback",
                                    "bound_agent_root_unavailable",
                                    "relay_backlog",
                                    "runner_exited",
                                    "relay_undeliverable",
                                    "interrupt_undeliverable"
                                  ]
                                }
                              },
                              "required": [
                                "code"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "level",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "router_switch"
                            },
                            "tier": {
                              "type": "string"
                            },
                            "route": {
                              "type": "string"
                            },
                            "fromModel": {
                              "type": "string"
                            },
                            "toModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            },
                            "trigger": {
                              "type": "string",
                              "enum": [
                                "first_turn",
                                "new_task",
                                "idle",
                                "manual_compact",
                                "overflow",
                                "modality_switch",
                                "tier_change"
                              ]
                            },
                            "rationale": {
                              "type": "string"
                            },
                            "probabilities": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "visionFallback": {
                              "type": "boolean"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "tier",
                            "route",
                            "fromModel",
                            "toModel",
                            "thinkingLevel",
                            "trigger",
                            "visionFallback"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "status"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "quiet": {
                              "type": "boolean",
                              "const": true
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "status": {
                              "type": "string",
                              "const": "ask"
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "questions"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "status": {
                              "type": "string",
                              "const": "interrupted"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "status": {
                              "type": "string",
                              "const": "sleep"
                            },
                            "wakeAt": {
                              "type": "number"
                            },
                            "pollWake": {
                              "type": "boolean"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "wakeAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "session_created"
                        },
                        "prompt": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "clientRequestId": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                        }
                      },
                      "required": [
                        "type",
                        "prompt",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "interrupt_requested"
                        },
                        "requestedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "requestedAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "agent_message"
                        },
                        "message": {
                          "type": "string",
                          "minLength": 1
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "message",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "view_shown"
                        },
                        "view": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "view",
                        "createdAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "prompt_submitted"
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "inputKind": {
                              "type": "string",
                              "enum": [
                                "initial",
                                "message"
                              ]
                            },
                            "behavior": {
                              "type": "string",
                              "enum": [
                                "steer",
                                "follow_up"
                              ]
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "prompt",
                            "inputKind",
                            "behavior",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "note_submitted"
                            },
                            "note": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "note",
                            "sender"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "answer_submitted"
                            },
                            "answer": {
                              "type": "string"
                            },
                            "sender": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "user"
                                    },
                                    "userId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "userId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "app"
                                    },
                                    "appId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "appId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "session"
                                    },
                                    "sessionId": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "required": [
                                    "kind",
                                    "sessionId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "system"
                                    }
                                  },
                                  "required": [
                                    "kind"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "clientRequestId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "images": {
                              "maxItems": 4,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "storageId": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "enum": [
                                      "image/png",
                                      "image/jpeg",
                                      "image/webp",
                                      "image/gif"
                                    ]
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 5242880
                                  }
                                },
                                "required": [
                                  "storageId",
                                  "mimeType",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "attachments": {
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "path": {
                                    "type": "string",
                                    "minLength": 1
                                  },
                                  "name": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "bytes": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "mimeType": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "path",
                                  "name",
                                  "bytes"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "dictated": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": [
                            "type",
                            "answer",
                            "sender"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    }
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": {}
                }
              ]
            },
            "createdAt": {
              "type": "number"
            }
          },
          "required": [
            "seq",
            "event",
            "createdAt"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "sessionId",
        "inputSeq",
        "url",
        "terminal"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "status": {
          "type": "string",
          "const": "running"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [
        "sessionId",
        "inputSeq",
        "status",
        "url"
      ],
      "additionalProperties": false
    }
  ]
}
Delivery
Standard response
Retry
Declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/history

Page through durable session events

CLI
bento session history list --session-id example
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cursor": {
      "type": "string",
      "minLength": 1
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "order": {
      "default": "desc",
      "type": "string",
      "enum": [
        "asc",
        "desc"
      ]
    },
    "view": {
      "default": "all",
      "type": "string",
      "enum": [
        "all",
        "transcript"
      ]
    },
    "afterSeq": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "beforeSeq": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    }
  },
  "additionalProperties": false
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "seq": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "event": {
            "anyOf": [
              {
                "anyOf": [
                  {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "turn_started"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "step"
                          },
                          "step": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "text_delta"
                                  },
                                  "delta": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "delta"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "reasoning_delta"
                                  },
                                  "delta": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "delta"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "text"
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "reasoning"
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "tool_call_start"
                                  },
                                  "toolName": {
                                    "type": "string"
                                  },
                                  "toolCallId": {
                                    "type": "string"
                                  },
                                  "input": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "type",
                                  "toolName",
                                  "toolCallId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "tool_call"
                                  },
                                  "toolName": {
                                    "type": "string"
                                  },
                                  "toolCallId": {
                                    "type": "string"
                                  },
                                  "input": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "isError": {
                                    "type": "boolean"
                                  },
                                  "output": {
                                    "type": "array",
                                    "items": {
                                      "oneOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "text"
                                            },
                                            "text": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "text"
                                          ],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "const": "image"
                                            },
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "type",
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      ]
                                    }
                                  },
                                  "details": {}
                                },
                                "required": [
                                  "type",
                                  "toolName",
                                  "toolCallId",
                                  "isError"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "system"
                                  },
                                  "message": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "message"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "step"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "task_started"
                          },
                          "task": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "tool",
                                  "subagent",
                                  "scheduled"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "ownerScopeId": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "pattern": "^turn-\\d+$"
                                  },
                                  {
                                    "type": "string",
                                    "pattern": "^task:t\\d+$"
                                  }
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "scheduled",
                                  "completed",
                                  "failed",
                                  "stopped",
                                  "lost"
                                ]
                              },
                              "startedAt": {
                                "type": "number"
                              },
                              "wakeAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "name",
                              "label",
                              "ownerScopeId",
                              "status",
                              "startedAt"
                            ],
                            "additionalProperties": false
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "task"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "task_output"
                          },
                          "taskId": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          },
                          "chunk": {
                            "type": "string"
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "taskId",
                          "chunk"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "task_settled"
                          },
                          "settlement": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "completed"
                                  },
                                  "settledAt": {
                                    "type": "number"
                                  },
                                  "result": {}
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "settledAt",
                                  "result"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "failed"
                                  },
                                  "settledAt": {
                                    "type": "number"
                                  },
                                  "error": {}
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "settledAt",
                                  "error"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "stopped"
                                  },
                                  "settledAt": {
                                    "type": "number"
                                  },
                                  "reason": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "settledAt",
                                  "reason"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "status": {
                                    "type": "string",
                                    "const": "lost"
                                  },
                                  "settledAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "id",
                                  "status",
                                  "settledAt"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "settlement"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "heartbeat"
                          },
                          "timestamp": {
                            "type": "number"
                          },
                          "activeTaskIds": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            }
                          }
                        },
                        "required": [
                          "type",
                          "timestamp",
                          "activeTaskIds"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "todos"
                          },
                          "todos": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "content": {
                                  "type": "string"
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "pending",
                                    "in_progress",
                                    "completed",
                                    "failed"
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "content",
                                "status"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "type",
                          "todos"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "follow_up_queue"
                          },
                          "followUpQueue": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "message": {
                                  "type": "string"
                                },
                                "images": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "data": {
                                        "type": "string"
                                      },
                                      "mimeType": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "data",
                                      "mimeType"
                                    ],
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "message"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "type",
                          "followUpQueue"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "state_machine"
                          },
                          "stateMachine": {
                            "type": "object",
                            "properties": {
                              "definition": {
                                "type": "object",
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "states": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "name",
                                  "prompt",
                                  "states"
                                ],
                                "additionalProperties": false
                              },
                              "prompt": {
                                "type": "string"
                              },
                              "currentState": {
                                "type": "string"
                              },
                              "currentInput": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              "progress": {
                                "type": "object",
                                "properties": {
                                  "states": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "states"
                                ],
                                "additionalProperties": {}
                              },
                              "history": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                }
                              },
                              "terminal": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              "terminalAcknowledged": {
                                "type": "boolean"
                              },
                              "createdAt": {
                                "type": "number"
                              },
                              "updatedAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "definition",
                              "prompt",
                              "history",
                              "createdAt",
                              "updatedAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "stateMachine"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "memory"
                          },
                          "phase": {
                            "type": "string",
                            "enum": [
                              "observation",
                              "reflection"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "running",
                              "completed"
                            ]
                          },
                          "message": {
                            "type": "string"
                          },
                          "observations": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            }
                          },
                          "usageBumpedObservations": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            }
                          }
                        },
                        "required": [
                          "type",
                          "phase",
                          "status",
                          "message"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "usage"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "turnUsage",
                          "usageByModel",
                          "lastMessageUsage",
                          "effectiveContextWindow",
                          "contextWindowUsage"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "system"
                          },
                          "level": {
                            "type": "string",
                            "enum": [
                              "debug",
                              "info",
                              "warn",
                              "error"
                            ]
                          },
                          "message": {
                            "type": "string"
                          },
                          "providerRecovery": {
                            "type": "object",
                            "properties": {
                              "fromModel": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "fromRoute": {
                                "type": "string",
                                "enum": [
                                  "configured",
                                  "vercel",
                                  "unknown"
                                ]
                              },
                              "toModel": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 256
                              },
                              "toRoute": {
                                "type": "string",
                                "const": "vercel"
                              },
                              "reason": {
                                "type": "string",
                                "enum": [
                                  "empty_response",
                                  "provider_error"
                                ]
                              },
                              "status": {
                                "type": "integer",
                                "minimum": 100,
                                "maximum": 599
                              }
                            },
                            "required": [
                              "fromModel",
                              "fromRoute",
                              "toModel",
                              "toRoute",
                              "reason"
                            ],
                            "additionalProperties": false
                          },
                          "metadata": {
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string",
                                "enum": [
                                  "storage_full",
                                  "session_cwd_fallback",
                                  "bound_agent_root_unavailable",
                                  "relay_backlog",
                                  "runner_exited",
                                  "relay_undeliverable",
                                  "interrupt_undeliverable"
                                ]
                              }
                            },
                            "required": [
                              "code"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "level",
                          "message"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "router_switch"
                          },
                          "tier": {
                            "type": "string"
                          },
                          "route": {
                            "type": "string"
                          },
                          "fromModel": {
                            "type": "string"
                          },
                          "toModel": {
                            "type": "string"
                          },
                          "thinkingLevel": {
                            "type": "string",
                            "enum": [
                              "minimal",
                              "low",
                              "medium",
                              "high",
                              "xhigh"
                            ]
                          },
                          "trigger": {
                            "type": "string",
                            "enum": [
                              "first_turn",
                              "new_task",
                              "idle",
                              "manual_compact",
                              "overflow",
                              "modality_switch",
                              "tier_change"
                            ]
                          },
                          "rationale": {
                            "type": "string"
                          },
                          "probabilities": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {
                              "type": "number"
                            }
                          },
                          "visionFallback": {
                            "type": "boolean"
                          },
                          "origin": {
                            "type": "object",
                            "properties": {
                              "taskId": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            },
                            "required": [
                              "taskId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "tier",
                          "route",
                          "fromModel",
                          "toModel",
                          "thinkingLevel",
                          "trigger",
                          "visionFallback"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "complete"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "completed",
                              "failed",
                              "cancelled"
                            ]
                          },
                          "result": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state",
                          "status"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "ask"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          },
                          "questions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "question": {
                                  "type": "string"
                                },
                                "header": {
                                  "type": "string"
                                },
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "label": {
                                        "type": "string"
                                      },
                                      "description": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "label"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "multiSelect": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "question",
                                "options"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state",
                          "questions"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "interrupted"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "sleep"
                          },
                          "state": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "waiting_for_human",
                                  "sleeping",
                                  "interrupted",
                                  "completed",
                                  "failed",
                                  "cancelled"
                                ]
                              },
                              "mode": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "const": "agent"
                                  },
                                  {
                                    "type": "string",
                                    "const": "auto"
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "options": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "memoryModel": {
                                    "type": "string"
                                  },
                                  "thinkingLevel": {
                                    "type": "string",
                                    "enum": [
                                      "minimal",
                                      "low",
                                      "medium",
                                      "high",
                                      "xhigh"
                                    ]
                                  }
                                },
                                "additionalProperties": false
                              },
                              "agent": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "running",
                                      "waiting",
                                      "completed",
                                      "failed",
                                      "cancelled"
                                    ]
                                  },
                                  "messages": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "role": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "role"
                                      ],
                                      "additionalProperties": {}
                                    }
                                  }
                                },
                                "required": [
                                  "status",
                                  "messages"
                                ],
                                "additionalProperties": false
                              },
                              "stateMachine": {
                                "type": "object",
                                "properties": {
                                  "definition": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "prompt": {
                                        "type": "string"
                                      },
                                      "states": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "prompt",
                                      "states"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "prompt": {
                                    "type": "string"
                                  },
                                  "currentState": {
                                    "type": "string"
                                  },
                                  "currentInput": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "progress": {
                                    "type": "object",
                                    "properties": {
                                      "states": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {}
                                        }
                                      }
                                    },
                                    "required": [
                                      "states"
                                    ],
                                    "additionalProperties": {}
                                  },
                                  "history": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "terminal": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  "terminalAcknowledged": {
                                    "type": "boolean"
                                  },
                                  "createdAt": {
                                    "type": "number"
                                  },
                                  "updatedAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "definition",
                                  "prompt",
                                  "history",
                                  "createdAt",
                                  "updatedAt"
                                ],
                                "additionalProperties": false
                              },
                              "pendingStateTransition": {
                                "type": "object",
                                "properties": {
                                  "stateName": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "stateName"
                                ],
                                "additionalProperties": false
                              },
                              "todos": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "content": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "pending",
                                        "in_progress",
                                        "completed",
                                        "failed"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "content",
                                    "status"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "followUpQueue": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "message": {
                                      "type": "string"
                                    },
                                    "images": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "data": {
                                            "type": "string"
                                          },
                                          "mimeType": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "data",
                                          "mimeType"
                                        ],
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "queuedCommands": {
                                "type": "array",
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "prompt"
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "message",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "answer"
                                        },
                                        "questions": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "question": {
                                                "type": "string"
                                              },
                                              "header": {
                                                "type": "string"
                                              },
                                              "options": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "description": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": [
                                                    "label"
                                                  ],
                                                  "additionalProperties": false
                                                }
                                              },
                                              "multiSelect": {
                                                "type": "boolean"
                                              }
                                            },
                                            "required": [
                                              "question",
                                              "options"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "answers": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "behavior": {
                                          "type": "string",
                                          "enum": [
                                            "steer",
                                            "follow_up"
                                          ]
                                        },
                                        "message": {
                                          "type": "string"
                                        },
                                        "images": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": [
                                        "type",
                                        "questions",
                                        "answers",
                                        "behavior"
                                      ],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "const": "wake"
                                        }
                                      },
                                      "required": [
                                        "type"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              },
                              "tasks": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": [
                                        "tool",
                                        "subagent",
                                        "scheduled"
                                      ]
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "ownerScopeId": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "pattern": "^turn-\\d+$"
                                        },
                                        {
                                          "type": "string",
                                          "pattern": "^task:t\\d+$"
                                        }
                                      ]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "scheduled",
                                        "completed",
                                        "failed",
                                        "stopped",
                                        "lost"
                                      ]
                                    },
                                    "startedAt": {
                                      "type": "number"
                                    },
                                    "wakeAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "kind",
                                    "name",
                                    "label",
                                    "ownerScopeId",
                                    "status",
                                    "startedAt"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "taskOutputTails": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "pendingLostTaskReminderTaskIds": {
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "nextTaskId": {
                                "type": "number"
                              },
                              "wireGuardHorizon": {
                                "type": "object",
                                "properties": {
                                  "evictionHorizon": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "evictionHorizon"
                                ],
                                "additionalProperties": false
                              },
                              "routing": {
                                "type": "object",
                                "properties": {
                                  "saved": {
                                    "type": "object",
                                    "properties": {
                                      "tier": {
                                        "type": "string"
                                      },
                                      "route": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "tier",
                                      "route"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "compactedSinceLastMessage": {
                                    "type": "boolean"
                                  },
                                  "currentTask": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "status",
                              "mode",
                              "agent"
                            ],
                            "additionalProperties": false
                          },
                          "wakeAt": {
                            "type": "number"
                          },
                          "pollWake": {
                            "type": "boolean"
                          },
                          "quiet": {
                            "type": "boolean",
                            "const": true
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "state",
                          "wakeAt"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "turn_started"
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "complete"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "completed",
                              "failed",
                              "cancelled"
                            ]
                          },
                          "result": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "ask"
                          },
                          "status": {
                            "type": "string",
                            "const": "ask"
                          },
                          "questions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "question": {
                                  "type": "string"
                                },
                                "header": {
                                  "type": "string"
                                },
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "label": {
                                        "type": "string"
                                      },
                                      "description": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "label"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "multiSelect": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "question",
                                "options"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "questions"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "interrupted"
                          },
                          "status": {
                            "type": "string",
                            "const": "interrupted"
                          },
                          "error": {
                            "type": "string"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "sleep"
                          },
                          "status": {
                            "type": "string",
                            "const": "sleep"
                          },
                          "wakeAt": {
                            "type": "number"
                          },
                          "pollWake": {
                            "type": "boolean"
                          },
                          "turnUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "usageByModel": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "model": {
                                  "type": "string"
                                },
                                "transport": {
                                  "type": "object",
                                  "properties": {
                                    "provider": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "duet-gateway",
                                            "vercel-ai-gateway",
                                            "openrouter"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "openai-codex",
                                            "github-copilot"
                                          ]
                                        }
                                      ]
                                    },
                                    "billing": {
                                      "type": "string",
                                      "enum": [
                                        "plan-covered",
                                        "metered"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "provider",
                                    "billing"
                                  ],
                                  "additionalProperties": false
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "cacheWrite1h": {
                                      "type": "number"
                                    },
                                    "totalTokens": {
                                      "type": "number"
                                    },
                                    "cost": {
                                      "type": "object",
                                      "properties": {
                                        "input": {
                                          "type": "number"
                                        },
                                        "output": {
                                          "type": "number"
                                        },
                                        "cacheRead": {
                                          "type": "number"
                                        },
                                        "cacheWrite": {
                                          "type": "number"
                                        },
                                        "total": {
                                          "type": "number"
                                        }
                                      },
                                      "required": [
                                        "input",
                                        "output",
                                        "cacheRead",
                                        "cacheWrite",
                                        "total"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "totalTokens",
                                    "cost"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "model",
                                "transport",
                                "usage"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "lastMessageUsage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          },
                          "effectiveContextWindow": {
                            "type": "number"
                          },
                          "contextWindowUsage": {
                            "type": "object",
                            "properties": {
                              "systemPrompt": {
                                "type": "number"
                              },
                              "messages": {
                                "type": "number"
                              },
                              "localMemory": {
                                "type": "number"
                              },
                              "globalMemory": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "systemPrompt",
                              "messages",
                              "localMemory",
                              "globalMemory"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "type",
                          "wakeAt"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "session_created"
                      },
                      "prompt": {
                        "type": "string"
                      },
                      "createdAt": {
                        "type": "string"
                      },
                      "clientRequestId": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      }
                    },
                    "required": [
                      "type",
                      "prompt",
                      "createdAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "interrupt_requested"
                      },
                      "requestedAt": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "requestedAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "agent_message"
                      },
                      "message": {
                        "type": "string",
                        "minLength": 1
                      },
                      "createdAt": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "message",
                      "createdAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "view_shown"
                      },
                      "view": {
                        "type": "string"
                      },
                      "createdAt": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "view",
                      "createdAt"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "prompt_submitted"
                          },
                          "prompt": {
                            "type": "string"
                          },
                          "inputKind": {
                            "type": "string",
                            "enum": [
                              "initial",
                              "message"
                            ]
                          },
                          "behavior": {
                            "type": "string",
                            "enum": [
                              "steer",
                              "follow_up"
                            ]
                          },
                          "sender": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "user"
                                  },
                                  "userId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "userId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "app"
                                  },
                                  "appId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "appId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "session"
                                  },
                                  "sessionId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "sessionId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "system"
                                  }
                                },
                                "required": [
                                  "kind"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "clientRequestId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "images": {
                            "maxItems": 4,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "storageId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "mimeType": {
                                  "type": "string",
                                  "enum": [
                                    "image/png",
                                    "image/jpeg",
                                    "image/webp",
                                    "image/gif"
                                  ]
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 5242880
                                }
                              },
                              "required": [
                                "storageId",
                                "mimeType",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "attachments": {
                            "maxItems": 10,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "path": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 255
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "mimeType": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "path",
                                "name",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "dictated": {
                            "type": "boolean",
                            "const": true
                          }
                        },
                        "required": [
                          "type",
                          "prompt",
                          "inputKind",
                          "behavior",
                          "sender"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "note_submitted"
                          },
                          "note": {
                            "type": "string"
                          },
                          "sender": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "user"
                                  },
                                  "userId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "userId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "app"
                                  },
                                  "appId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "appId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "session"
                                  },
                                  "sessionId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "sessionId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "system"
                                  }
                                },
                                "required": [
                                  "kind"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "clientRequestId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "images": {
                            "maxItems": 4,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "storageId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "mimeType": {
                                  "type": "string",
                                  "enum": [
                                    "image/png",
                                    "image/jpeg",
                                    "image/webp",
                                    "image/gif"
                                  ]
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 5242880
                                }
                              },
                              "required": [
                                "storageId",
                                "mimeType",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "attachments": {
                            "maxItems": 10,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "path": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 255
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "mimeType": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "path",
                                "name",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "dictated": {
                            "type": "boolean",
                            "const": true
                          }
                        },
                        "required": [
                          "type",
                          "note",
                          "sender"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "answer_submitted"
                          },
                          "answer": {
                            "type": "string"
                          },
                          "sender": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "user"
                                  },
                                  "userId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "userId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "app"
                                  },
                                  "appId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "appId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "session"
                                  },
                                  "sessionId": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": [
                                  "kind",
                                  "sessionId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "system"
                                  }
                                },
                                "required": [
                                  "kind"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "clientRequestId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "images": {
                            "maxItems": 4,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "storageId": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "mimeType": {
                                  "type": "string",
                                  "enum": [
                                    "image/png",
                                    "image/jpeg",
                                    "image/webp",
                                    "image/gif"
                                  ]
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 5242880
                                }
                              },
                              "required": [
                                "storageId",
                                "mimeType",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "attachments": {
                            "maxItems": 10,
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "path": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "name": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 255
                                },
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "mimeType": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "required": [
                                "path",
                                "name",
                                "bytes"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "dictated": {
                            "type": "boolean",
                            "const": true
                          }
                        },
                        "required": [
                          "type",
                          "answer",
                          "sender"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  }
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": {}
              }
            ]
          },
          "createdAt": {
            "type": "number"
          }
        },
        "required": [
          "seq",
          "event",
          "createdAt"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false
}
Errors
Error body JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "not_found"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "The session is unavailable to this caller (404)"
    },
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string",
          "const": "invalid_cursor"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false,
      "description": "Opaque collection cursor is malformed or bound to another walk (400)"
    }
  ]
}
Delivery
Standard response
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/history/events

Resume a session event stream

Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {},
  "additionalProperties": false
}
Headers
  • Last-Event-ID โ€” Resume after the last committed numeric sequence.
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "seq": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "createdAt": {
      "type": "number"
    },
    "event": {
      "anyOf": [
        {
          "anyOf": [
            {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "turn_started"
                    },
                    "state": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "running",
                            "waiting_for_human",
                            "sleeping",
                            "interrupted",
                            "completed",
                            "failed",
                            "cancelled"
                          ]
                        },
                        "mode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "const": "agent"
                            },
                            {
                              "type": "string",
                              "const": "auto"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "options": {
                          "type": "object",
                          "properties": {
                            "model": {
                              "type": "string"
                            },
                            "memoryModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            }
                          },
                          "additionalProperties": false
                        },
                        "agent": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "waiting",
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "messages": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "role": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "role"
                                ],
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "status",
                            "messages"
                          ],
                          "additionalProperties": false
                        },
                        "stateMachine": {
                          "type": "object",
                          "properties": {
                            "definition": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "currentState": {
                              "type": "string"
                            },
                            "currentInput": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "progress": {
                              "type": "object",
                              "properties": {
                                "states": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "states"
                              ],
                              "additionalProperties": {}
                            },
                            "history": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "terminal": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "terminalAcknowledged": {
                              "type": "boolean"
                            },
                            "createdAt": {
                              "type": "number"
                            },
                            "updatedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "definition",
                            "prompt",
                            "history",
                            "createdAt",
                            "updatedAt"
                          ],
                          "additionalProperties": false
                        },
                        "pendingStateTransition": {
                          "type": "object",
                          "properties": {
                            "stateName": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "stateName"
                          ],
                          "additionalProperties": false
                        },
                        "todos": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "content": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pending",
                                  "in_progress",
                                  "completed",
                                  "failed"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "content",
                              "status"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "followUpQueue": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string"
                              },
                              "images": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "data": {
                                      "type": "string"
                                    },
                                    "mimeType": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "data",
                                    "mimeType"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "message"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "queuedCommands": {
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "prompt"
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "message",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "answer"
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "answers": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "questions",
                                  "answers",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "wake"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "tasks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "tool",
                                  "subagent",
                                  "scheduled"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "ownerScopeId": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "pattern": "^turn-\\d+$"
                                  },
                                  {
                                    "type": "string",
                                    "pattern": "^task:t\\d+$"
                                  }
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "scheduled",
                                  "completed",
                                  "failed",
                                  "stopped",
                                  "lost"
                                ]
                              },
                              "startedAt": {
                                "type": "number"
                              },
                              "wakeAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "name",
                              "label",
                              "ownerScopeId",
                              "status",
                              "startedAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "taskOutputTails": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          },
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "pendingLostTaskReminderTaskIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          }
                        },
                        "nextTaskId": {
                          "type": "number"
                        },
                        "wireGuardHorizon": {
                          "type": "object",
                          "properties": {
                            "evictionHorizon": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "evictionHorizon"
                          ],
                          "additionalProperties": false
                        },
                        "routing": {
                          "type": "object",
                          "properties": {
                            "saved": {
                              "type": "object",
                              "properties": {
                                "tier": {
                                  "type": "string"
                                },
                                "route": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "tier",
                                "route"
                              ],
                              "additionalProperties": false
                            },
                            "compactedSinceLastMessage": {
                              "type": "boolean"
                            },
                            "currentTask": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "status",
                        "mode",
                        "agent"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "state"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "step"
                    },
                    "step": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "text_delta"
                            },
                            "delta": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "delta"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "reasoning_delta"
                            },
                            "delta": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "delta"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "text"
                            },
                            "text": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "text"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "reasoning"
                            },
                            "text": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "text"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "tool_call_start"
                            },
                            "toolName": {
                              "type": "string"
                            },
                            "toolCallId": {
                              "type": "string"
                            },
                            "input": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            }
                          },
                          "required": [
                            "type",
                            "toolName",
                            "toolCallId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "tool_call"
                            },
                            "toolName": {
                              "type": "string"
                            },
                            "toolCallId": {
                              "type": "string"
                            },
                            "input": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "isError": {
                              "type": "boolean"
                            },
                            "output": {
                              "type": "array",
                              "items": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "text"
                                      },
                                      "text": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "text"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "const": "image"
                                      },
                                      "data": {
                                        "type": "string"
                                      },
                                      "mimeType": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "data",
                                      "mimeType"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              }
                            },
                            "details": {}
                          },
                          "required": [
                            "type",
                            "toolName",
                            "toolCallId",
                            "isError"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "system"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "message"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "origin": {
                      "type": "object",
                      "properties": {
                        "taskId": {
                          "type": "string",
                          "pattern": "^t\\d+$"
                        }
                      },
                      "required": [
                        "taskId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "step"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "task_started"
                    },
                    "task": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "pattern": "^t\\d+$"
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "tool",
                            "subagent",
                            "scheduled"
                          ]
                        },
                        "name": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        },
                        "ownerScopeId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "pattern": "^turn-\\d+$"
                            },
                            {
                              "type": "string",
                              "pattern": "^task:t\\d+$"
                            }
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "running",
                            "scheduled",
                            "completed",
                            "failed",
                            "stopped",
                            "lost"
                          ]
                        },
                        "startedAt": {
                          "type": "number"
                        },
                        "wakeAt": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "id",
                        "kind",
                        "name",
                        "label",
                        "ownerScopeId",
                        "status",
                        "startedAt"
                      ],
                      "additionalProperties": false
                    },
                    "origin": {
                      "type": "object",
                      "properties": {
                        "taskId": {
                          "type": "string",
                          "pattern": "^t\\d+$"
                        }
                      },
                      "required": [
                        "taskId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "task"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "task_output"
                    },
                    "taskId": {
                      "type": "string",
                      "pattern": "^t\\d+$"
                    },
                    "chunk": {
                      "type": "string"
                    },
                    "origin": {
                      "type": "object",
                      "properties": {
                        "taskId": {
                          "type": "string",
                          "pattern": "^t\\d+$"
                        }
                      },
                      "required": [
                        "taskId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "taskId",
                    "chunk"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "task_settled"
                    },
                    "settlement": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "status": {
                              "type": "string",
                              "const": "completed"
                            },
                            "settledAt": {
                              "type": "number"
                            },
                            "result": {}
                          },
                          "required": [
                            "id",
                            "status",
                            "settledAt",
                            "result"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "status": {
                              "type": "string",
                              "const": "failed"
                            },
                            "settledAt": {
                              "type": "number"
                            },
                            "error": {}
                          },
                          "required": [
                            "id",
                            "status",
                            "settledAt",
                            "error"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "status": {
                              "type": "string",
                              "const": "stopped"
                            },
                            "settledAt": {
                              "type": "number"
                            },
                            "reason": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "status",
                            "settledAt",
                            "reason"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "status": {
                              "type": "string",
                              "const": "lost"
                            },
                            "settledAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "id",
                            "status",
                            "settledAt"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "origin": {
                      "type": "object",
                      "properties": {
                        "taskId": {
                          "type": "string",
                          "pattern": "^t\\d+$"
                        }
                      },
                      "required": [
                        "taskId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "settlement"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "heartbeat"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "activeTaskIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^t\\d+$"
                      }
                    }
                  },
                  "required": [
                    "type",
                    "timestamp",
                    "activeTaskIds"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "todos"
                    },
                    "todos": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "in_progress",
                              "completed",
                              "failed"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "content",
                          "status"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "type",
                    "todos"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "follow_up_queue"
                    },
                    "followUpQueue": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "message": {
                            "type": "string"
                          },
                          "images": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "data": {
                                  "type": "string"
                                },
                                "mimeType": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "data",
                                "mimeType"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "message"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "type",
                    "followUpQueue"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "state_machine"
                    },
                    "stateMachine": {
                      "type": "object",
                      "properties": {
                        "definition": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "states": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "name",
                            "prompt",
                            "states"
                          ],
                          "additionalProperties": false
                        },
                        "prompt": {
                          "type": "string"
                        },
                        "currentState": {
                          "type": "string"
                        },
                        "currentInput": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        "progress": {
                          "type": "object",
                          "properties": {
                            "states": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "states"
                          ],
                          "additionalProperties": {}
                        },
                        "history": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          }
                        },
                        "terminal": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        "terminalAcknowledged": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "updatedAt": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "definition",
                        "prompt",
                        "history",
                        "createdAt",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "stateMachine"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "memory"
                    },
                    "phase": {
                      "type": "string",
                      "enum": [
                        "observation",
                        "reflection"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "running",
                        "completed"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "observations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    },
                    "usageBumpedObservations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    }
                  },
                  "required": [
                    "type",
                    "phase",
                    "status",
                    "message"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "usage"
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    },
                    "origin": {
                      "type": "object",
                      "properties": {
                        "taskId": {
                          "type": "string",
                          "pattern": "^t\\d+$"
                        }
                      },
                      "required": [
                        "taskId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "turnUsage",
                    "usageByModel",
                    "lastMessageUsage",
                    "effectiveContextWindow",
                    "contextWindowUsage"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "system"
                    },
                    "level": {
                      "type": "string",
                      "enum": [
                        "debug",
                        "info",
                        "warn",
                        "error"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "providerRecovery": {
                      "type": "object",
                      "properties": {
                        "fromModel": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "fromRoute": {
                          "type": "string",
                          "enum": [
                            "configured",
                            "vercel",
                            "unknown"
                          ]
                        },
                        "toModel": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "toRoute": {
                          "type": "string",
                          "const": "vercel"
                        },
                        "reason": {
                          "type": "string",
                          "enum": [
                            "empty_response",
                            "provider_error"
                          ]
                        },
                        "status": {
                          "type": "integer",
                          "minimum": 100,
                          "maximum": 599
                        }
                      },
                      "required": [
                        "fromModel",
                        "fromRoute",
                        "toModel",
                        "toRoute",
                        "reason"
                      ],
                      "additionalProperties": false
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "storage_full",
                            "session_cwd_fallback",
                            "bound_agent_root_unavailable",
                            "relay_backlog",
                            "runner_exited",
                            "relay_undeliverable",
                            "interrupt_undeliverable"
                          ]
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "level",
                    "message"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "router_switch"
                    },
                    "tier": {
                      "type": "string"
                    },
                    "route": {
                      "type": "string"
                    },
                    "fromModel": {
                      "type": "string"
                    },
                    "toModel": {
                      "type": "string"
                    },
                    "thinkingLevel": {
                      "type": "string",
                      "enum": [
                        "minimal",
                        "low",
                        "medium",
                        "high",
                        "xhigh"
                      ]
                    },
                    "trigger": {
                      "type": "string",
                      "enum": [
                        "first_turn",
                        "new_task",
                        "idle",
                        "manual_compact",
                        "overflow",
                        "modality_switch",
                        "tier_change"
                      ]
                    },
                    "rationale": {
                      "type": "string"
                    },
                    "probabilities": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "visionFallback": {
                      "type": "boolean"
                    },
                    "origin": {
                      "type": "object",
                      "properties": {
                        "taskId": {
                          "type": "string",
                          "pattern": "^t\\d+$"
                        }
                      },
                      "required": [
                        "taskId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "tier",
                    "route",
                    "fromModel",
                    "toModel",
                    "thinkingLevel",
                    "trigger",
                    "visionFallback"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "complete"
                    },
                    "state": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "running",
                            "waiting_for_human",
                            "sleeping",
                            "interrupted",
                            "completed",
                            "failed",
                            "cancelled"
                          ]
                        },
                        "mode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "const": "agent"
                            },
                            {
                              "type": "string",
                              "const": "auto"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "options": {
                          "type": "object",
                          "properties": {
                            "model": {
                              "type": "string"
                            },
                            "memoryModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            }
                          },
                          "additionalProperties": false
                        },
                        "agent": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "waiting",
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "messages": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "role": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "role"
                                ],
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "status",
                            "messages"
                          ],
                          "additionalProperties": false
                        },
                        "stateMachine": {
                          "type": "object",
                          "properties": {
                            "definition": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "currentState": {
                              "type": "string"
                            },
                            "currentInput": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "progress": {
                              "type": "object",
                              "properties": {
                                "states": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "states"
                              ],
                              "additionalProperties": {}
                            },
                            "history": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "terminal": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "terminalAcknowledged": {
                              "type": "boolean"
                            },
                            "createdAt": {
                              "type": "number"
                            },
                            "updatedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "definition",
                            "prompt",
                            "history",
                            "createdAt",
                            "updatedAt"
                          ],
                          "additionalProperties": false
                        },
                        "pendingStateTransition": {
                          "type": "object",
                          "properties": {
                            "stateName": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "stateName"
                          ],
                          "additionalProperties": false
                        },
                        "todos": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "content": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pending",
                                  "in_progress",
                                  "completed",
                                  "failed"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "content",
                              "status"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "followUpQueue": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string"
                              },
                              "images": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "data": {
                                      "type": "string"
                                    },
                                    "mimeType": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "data",
                                    "mimeType"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "message"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "queuedCommands": {
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "prompt"
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "message",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "answer"
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "answers": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "questions",
                                  "answers",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "wake"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "tasks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "tool",
                                  "subagent",
                                  "scheduled"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "ownerScopeId": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "pattern": "^turn-\\d+$"
                                  },
                                  {
                                    "type": "string",
                                    "pattern": "^task:t\\d+$"
                                  }
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "scheduled",
                                  "completed",
                                  "failed",
                                  "stopped",
                                  "lost"
                                ]
                              },
                              "startedAt": {
                                "type": "number"
                              },
                              "wakeAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "name",
                              "label",
                              "ownerScopeId",
                              "status",
                              "startedAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "taskOutputTails": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          },
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "pendingLostTaskReminderTaskIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          }
                        },
                        "nextTaskId": {
                          "type": "number"
                        },
                        "wireGuardHorizon": {
                          "type": "object",
                          "properties": {
                            "evictionHorizon": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "evictionHorizon"
                          ],
                          "additionalProperties": false
                        },
                        "routing": {
                          "type": "object",
                          "properties": {
                            "saved": {
                              "type": "object",
                              "properties": {
                                "tier": {
                                  "type": "string"
                                },
                                "route": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "tier",
                                "route"
                              ],
                              "additionalProperties": false
                            },
                            "compactedSinceLastMessage": {
                              "type": "boolean"
                            },
                            "currentTask": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "status",
                        "mode",
                        "agent"
                      ],
                      "additionalProperties": false
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "completed",
                        "failed",
                        "cancelled"
                      ]
                    },
                    "result": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "state",
                    "status"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "ask"
                    },
                    "state": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "running",
                            "waiting_for_human",
                            "sleeping",
                            "interrupted",
                            "completed",
                            "failed",
                            "cancelled"
                          ]
                        },
                        "mode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "const": "agent"
                            },
                            {
                              "type": "string",
                              "const": "auto"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "options": {
                          "type": "object",
                          "properties": {
                            "model": {
                              "type": "string"
                            },
                            "memoryModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            }
                          },
                          "additionalProperties": false
                        },
                        "agent": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "waiting",
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "messages": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "role": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "role"
                                ],
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "status",
                            "messages"
                          ],
                          "additionalProperties": false
                        },
                        "stateMachine": {
                          "type": "object",
                          "properties": {
                            "definition": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "currentState": {
                              "type": "string"
                            },
                            "currentInput": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "progress": {
                              "type": "object",
                              "properties": {
                                "states": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "states"
                              ],
                              "additionalProperties": {}
                            },
                            "history": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "terminal": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "terminalAcknowledged": {
                              "type": "boolean"
                            },
                            "createdAt": {
                              "type": "number"
                            },
                            "updatedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "definition",
                            "prompt",
                            "history",
                            "createdAt",
                            "updatedAt"
                          ],
                          "additionalProperties": false
                        },
                        "pendingStateTransition": {
                          "type": "object",
                          "properties": {
                            "stateName": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "stateName"
                          ],
                          "additionalProperties": false
                        },
                        "todos": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "content": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pending",
                                  "in_progress",
                                  "completed",
                                  "failed"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "content",
                              "status"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "followUpQueue": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string"
                              },
                              "images": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "data": {
                                      "type": "string"
                                    },
                                    "mimeType": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "data",
                                    "mimeType"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "message"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "queuedCommands": {
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "prompt"
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "message",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "answer"
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "answers": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "questions",
                                  "answers",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "wake"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "tasks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "tool",
                                  "subagent",
                                  "scheduled"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "ownerScopeId": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "pattern": "^turn-\\d+$"
                                  },
                                  {
                                    "type": "string",
                                    "pattern": "^task:t\\d+$"
                                  }
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "scheduled",
                                  "completed",
                                  "failed",
                                  "stopped",
                                  "lost"
                                ]
                              },
                              "startedAt": {
                                "type": "number"
                              },
                              "wakeAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "name",
                              "label",
                              "ownerScopeId",
                              "status",
                              "startedAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "taskOutputTails": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          },
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "pendingLostTaskReminderTaskIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          }
                        },
                        "nextTaskId": {
                          "type": "number"
                        },
                        "wireGuardHorizon": {
                          "type": "object",
                          "properties": {
                            "evictionHorizon": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "evictionHorizon"
                          ],
                          "additionalProperties": false
                        },
                        "routing": {
                          "type": "object",
                          "properties": {
                            "saved": {
                              "type": "object",
                              "properties": {
                                "tier": {
                                  "type": "string"
                                },
                                "route": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "tier",
                                "route"
                              ],
                              "additionalProperties": false
                            },
                            "compactedSinceLastMessage": {
                              "type": "boolean"
                            },
                            "currentTask": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "status",
                        "mode",
                        "agent"
                      ],
                      "additionalProperties": false
                    },
                    "questions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "question": {
                            "type": "string"
                          },
                          "header": {
                            "type": "string"
                          },
                          "options": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "label": {
                                  "type": "string"
                                },
                                "description": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "label"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "multiSelect": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "question",
                          "options"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "state",
                    "questions"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "interrupted"
                    },
                    "state": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "running",
                            "waiting_for_human",
                            "sleeping",
                            "interrupted",
                            "completed",
                            "failed",
                            "cancelled"
                          ]
                        },
                        "mode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "const": "agent"
                            },
                            {
                              "type": "string",
                              "const": "auto"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "options": {
                          "type": "object",
                          "properties": {
                            "model": {
                              "type": "string"
                            },
                            "memoryModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            }
                          },
                          "additionalProperties": false
                        },
                        "agent": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "waiting",
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "messages": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "role": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "role"
                                ],
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "status",
                            "messages"
                          ],
                          "additionalProperties": false
                        },
                        "stateMachine": {
                          "type": "object",
                          "properties": {
                            "definition": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "currentState": {
                              "type": "string"
                            },
                            "currentInput": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "progress": {
                              "type": "object",
                              "properties": {
                                "states": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "states"
                              ],
                              "additionalProperties": {}
                            },
                            "history": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "terminal": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "terminalAcknowledged": {
                              "type": "boolean"
                            },
                            "createdAt": {
                              "type": "number"
                            },
                            "updatedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "definition",
                            "prompt",
                            "history",
                            "createdAt",
                            "updatedAt"
                          ],
                          "additionalProperties": false
                        },
                        "pendingStateTransition": {
                          "type": "object",
                          "properties": {
                            "stateName": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "stateName"
                          ],
                          "additionalProperties": false
                        },
                        "todos": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "content": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pending",
                                  "in_progress",
                                  "completed",
                                  "failed"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "content",
                              "status"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "followUpQueue": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string"
                              },
                              "images": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "data": {
                                      "type": "string"
                                    },
                                    "mimeType": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "data",
                                    "mimeType"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "message"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "queuedCommands": {
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "prompt"
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "message",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "answer"
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "answers": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "questions",
                                  "answers",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "wake"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "tasks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "tool",
                                  "subagent",
                                  "scheduled"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "ownerScopeId": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "pattern": "^turn-\\d+$"
                                  },
                                  {
                                    "type": "string",
                                    "pattern": "^task:t\\d+$"
                                  }
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "scheduled",
                                  "completed",
                                  "failed",
                                  "stopped",
                                  "lost"
                                ]
                              },
                              "startedAt": {
                                "type": "number"
                              },
                              "wakeAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "name",
                              "label",
                              "ownerScopeId",
                              "status",
                              "startedAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "taskOutputTails": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          },
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "pendingLostTaskReminderTaskIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          }
                        },
                        "nextTaskId": {
                          "type": "number"
                        },
                        "wireGuardHorizon": {
                          "type": "object",
                          "properties": {
                            "evictionHorizon": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "evictionHorizon"
                          ],
                          "additionalProperties": false
                        },
                        "routing": {
                          "type": "object",
                          "properties": {
                            "saved": {
                              "type": "object",
                              "properties": {
                                "tier": {
                                  "type": "string"
                                },
                                "route": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "tier",
                                "route"
                              ],
                              "additionalProperties": false
                            },
                            "compactedSinceLastMessage": {
                              "type": "boolean"
                            },
                            "currentTask": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "status",
                        "mode",
                        "agent"
                      ],
                      "additionalProperties": false
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "state"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "sleep"
                    },
                    "state": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "running",
                            "waiting_for_human",
                            "sleeping",
                            "interrupted",
                            "completed",
                            "failed",
                            "cancelled"
                          ]
                        },
                        "mode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "const": "agent"
                            },
                            {
                              "type": "string",
                              "const": "auto"
                            },
                            {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "options": {
                          "type": "object",
                          "properties": {
                            "model": {
                              "type": "string"
                            },
                            "memoryModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            }
                          },
                          "additionalProperties": false
                        },
                        "agent": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "waiting",
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "messages": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "role": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "role"
                                ],
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "status",
                            "messages"
                          ],
                          "additionalProperties": false
                        },
                        "stateMachine": {
                          "type": "object",
                          "properties": {
                            "definition": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "states": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "name",
                                "prompt",
                                "states"
                              ],
                              "additionalProperties": false
                            },
                            "prompt": {
                              "type": "string"
                            },
                            "currentState": {
                              "type": "string"
                            },
                            "currentInput": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "progress": {
                              "type": "object",
                              "properties": {
                                "states": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                }
                              },
                              "required": [
                                "states"
                              ],
                              "additionalProperties": {}
                            },
                            "history": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "terminal": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "terminalAcknowledged": {
                              "type": "boolean"
                            },
                            "createdAt": {
                              "type": "number"
                            },
                            "updatedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "definition",
                            "prompt",
                            "history",
                            "createdAt",
                            "updatedAt"
                          ],
                          "additionalProperties": false
                        },
                        "pendingStateTransition": {
                          "type": "object",
                          "properties": {
                            "stateName": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "stateName"
                          ],
                          "additionalProperties": false
                        },
                        "todos": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "content": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pending",
                                  "in_progress",
                                  "completed",
                                  "failed"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "content",
                              "status"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "followUpQueue": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string"
                              },
                              "images": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "data": {
                                      "type": "string"
                                    },
                                    "mimeType": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "data",
                                    "mimeType"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "message"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "queuedCommands": {
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "prompt"
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "message",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "answer"
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "header": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "description": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "label"
                                            ],
                                            "additionalProperties": false
                                          }
                                        },
                                        "multiSelect": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": [
                                        "question",
                                        "options"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "answers": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "behavior": {
                                    "type": "string",
                                    "enum": [
                                      "steer",
                                      "follow_up"
                                    ]
                                  },
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "type",
                                  "questions",
                                  "answers",
                                  "behavior"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "wake"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          }
                        },
                        "tasks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "tool",
                                  "subagent",
                                  "scheduled"
                                ]
                              },
                              "name": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "ownerScopeId": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "pattern": "^turn-\\d+$"
                                  },
                                  {
                                    "type": "string",
                                    "pattern": "^task:t\\d+$"
                                  }
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "scheduled",
                                  "completed",
                                  "failed",
                                  "stopped",
                                  "lost"
                                ]
                              },
                              "startedAt": {
                                "type": "number"
                              },
                              "wakeAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "name",
                              "label",
                              "ownerScopeId",
                              "status",
                              "startedAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "taskOutputTails": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          },
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "pendingLostTaskReminderTaskIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^t\\d+$"
                          }
                        },
                        "nextTaskId": {
                          "type": "number"
                        },
                        "wireGuardHorizon": {
                          "type": "object",
                          "properties": {
                            "evictionHorizon": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "evictionHorizon"
                          ],
                          "additionalProperties": false
                        },
                        "routing": {
                          "type": "object",
                          "properties": {
                            "saved": {
                              "type": "object",
                              "properties": {
                                "tier": {
                                  "type": "string"
                                },
                                "route": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "tier",
                                "route"
                              ],
                              "additionalProperties": false
                            },
                            "compactedSinceLastMessage": {
                              "type": "boolean"
                            },
                            "currentTask": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "status",
                        "mode",
                        "agent"
                      ],
                      "additionalProperties": false
                    },
                    "wakeAt": {
                      "type": "number"
                    },
                    "pollWake": {
                      "type": "boolean"
                    },
                    "quiet": {
                      "type": "boolean",
                      "const": true
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "state",
                    "wakeAt"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "turn_started"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "complete"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "completed",
                        "failed",
                        "cancelled"
                      ]
                    },
                    "result": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "ask"
                    },
                    "status": {
                      "type": "string",
                      "const": "ask"
                    },
                    "questions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "question": {
                            "type": "string"
                          },
                          "header": {
                            "type": "string"
                          },
                          "options": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "label": {
                                  "type": "string"
                                },
                                "description": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "label"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "multiSelect": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "question",
                          "options"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "questions"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "interrupted"
                    },
                    "status": {
                      "type": "string",
                      "const": "interrupted"
                    },
                    "error": {
                      "type": "string"
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "sleep"
                    },
                    "status": {
                      "type": "string",
                      "const": "sleep"
                    },
                    "wakeAt": {
                      "type": "number"
                    },
                    "pollWake": {
                      "type": "boolean"
                    },
                    "turnUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "usageByModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "transport": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "duet-gateway",
                                      "vercel-ai-gateway",
                                      "openrouter"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "openai-codex",
                                      "github-copilot"
                                    ]
                                  }
                                ]
                              },
                              "billing": {
                                "type": "string",
                                "enum": [
                                  "plan-covered",
                                  "metered"
                                ]
                              }
                            },
                            "required": [
                              "provider",
                              "billing"
                            ],
                            "additionalProperties": false
                          },
                          "usage": {
                            "type": "object",
                            "properties": {
                              "input": {
                                "type": "number"
                              },
                              "output": {
                                "type": "number"
                              },
                              "cacheRead": {
                                "type": "number"
                              },
                              "cacheWrite": {
                                "type": "number"
                              },
                              "cacheWrite1h": {
                                "type": "number"
                              },
                              "totalTokens": {
                                "type": "number"
                              },
                              "cost": {
                                "type": "object",
                                "properties": {
                                  "input": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "number"
                                  },
                                  "cacheRead": {
                                    "type": "number"
                                  },
                                  "cacheWrite": {
                                    "type": "number"
                                  },
                                  "total": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "input",
                                  "output",
                                  "cacheRead",
                                  "cacheWrite",
                                  "total"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "input",
                              "output",
                              "cacheRead",
                              "cacheWrite",
                              "totalTokens",
                              "cost"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "model",
                          "transport",
                          "usage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "lastMessageUsage": {
                      "type": "object",
                      "properties": {
                        "input": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "cacheWrite1h": {
                          "type": "number"
                        },
                        "totalTokens": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "object",
                          "properties": {
                            "input": {
                              "type": "number"
                            },
                            "output": {
                              "type": "number"
                            },
                            "cacheRead": {
                              "type": "number"
                            },
                            "cacheWrite": {
                              "type": "number"
                            },
                            "total": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "input",
                            "output",
                            "cacheRead",
                            "cacheWrite",
                            "total"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "input",
                        "output",
                        "cacheRead",
                        "cacheWrite",
                        "totalTokens",
                        "cost"
                      ],
                      "additionalProperties": false
                    },
                    "effectiveContextWindow": {
                      "type": "number"
                    },
                    "contextWindowUsage": {
                      "type": "object",
                      "properties": {
                        "systemPrompt": {
                          "type": "number"
                        },
                        "messages": {
                          "type": "number"
                        },
                        "localMemory": {
                          "type": "number"
                        },
                        "globalMemory": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "systemPrompt",
                        "messages",
                        "localMemory",
                        "globalMemory"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "wakeAt"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "session_created"
                },
                "prompt": {
                  "type": "string"
                },
                "createdAt": {
                  "type": "string"
                },
                "clientRequestId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                }
              },
              "required": [
                "type",
                "prompt",
                "createdAt"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "interrupt_requested"
                },
                "requestedAt": {
                  "type": "string"
                }
              },
              "required": [
                "type",
                "requestedAt"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "agent_message"
                },
                "message": {
                  "type": "string",
                  "minLength": 1
                },
                "createdAt": {
                  "type": "string"
                }
              },
              "required": [
                "type",
                "message",
                "createdAt"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "view_shown"
                },
                "view": {
                  "type": "string"
                },
                "createdAt": {
                  "type": "string"
                }
              },
              "required": [
                "type",
                "view",
                "createdAt"
              ],
              "additionalProperties": false
            },
            {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "prompt_submitted"
                    },
                    "prompt": {
                      "type": "string"
                    },
                    "inputKind": {
                      "type": "string",
                      "enum": [
                        "initial",
                        "message"
                      ]
                    },
                    "behavior": {
                      "type": "string",
                      "enum": [
                        "steer",
                        "follow_up"
                      ]
                    },
                    "sender": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "user"
                            },
                            "userId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "userId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "app"
                            },
                            "appId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "appId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "session"
                            },
                            "sessionId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "sessionId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "system"
                            }
                          },
                          "required": [
                            "kind"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "clientRequestId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "images": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "storageId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "mimeType": {
                            "type": "string",
                            "enum": [
                              "image/png",
                              "image/jpeg",
                              "image/webp",
                              "image/gif"
                            ]
                          },
                          "bytes": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 5242880
                          }
                        },
                        "required": [
                          "storageId",
                          "mimeType",
                          "bytes"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "attachments": {
                      "maxItems": 10,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string",
                            "minLength": 1
                          },
                          "name": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 255
                          },
                          "bytes": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          "mimeType": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": [
                          "path",
                          "name",
                          "bytes"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "dictated": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "type",
                    "prompt",
                    "inputKind",
                    "behavior",
                    "sender"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "note_submitted"
                    },
                    "note": {
                      "type": "string"
                    },
                    "sender": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "user"
                            },
                            "userId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "userId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "app"
                            },
                            "appId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "appId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "session"
                            },
                            "sessionId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "sessionId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "system"
                            }
                          },
                          "required": [
                            "kind"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "clientRequestId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "images": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "storageId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "mimeType": {
                            "type": "string",
                            "enum": [
                              "image/png",
                              "image/jpeg",
                              "image/webp",
                              "image/gif"
                            ]
                          },
                          "bytes": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 5242880
                          }
                        },
                        "required": [
                          "storageId",
                          "mimeType",
                          "bytes"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "attachments": {
                      "maxItems": 10,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string",
                            "minLength": 1
                          },
                          "name": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 255
                          },
                          "bytes": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          "mimeType": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": [
                          "path",
                          "name",
                          "bytes"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "dictated": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "type",
                    "note",
                    "sender"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "answer_submitted"
                    },
                    "answer": {
                      "type": "string"
                    },
                    "sender": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "user"
                            },
                            "userId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "userId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "app"
                            },
                            "appId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "appId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "session"
                            },
                            "sessionId": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "kind",
                            "sessionId"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "const": "system"
                            }
                          },
                          "required": [
                            "kind"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "clientRequestId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "images": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "storageId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "mimeType": {
                            "type": "string",
                            "enum": [
                              "image/png",
                              "image/jpeg",
                              "image/webp",
                              "image/gif"
                            ]
                          },
                          "bytes": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 5242880
                          }
                        },
                        "required": [
                          "storageId",
                          "mimeType",
                          "bytes"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "attachments": {
                      "maxItems": 10,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string",
                            "minLength": 1
                          },
                          "name": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 255
                          },
                          "bytes": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          "mimeType": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": [
                          "path",
                          "name",
                          "bytes"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "dictated": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "type",
                    "answer",
                    "sender"
                  ],
                  "additionalProperties": false
                }
              ]
            }
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string"
            }
          },
          "required": [
            "type"
          ],
          "additionalProperties": {}
        }
      ]
    }
  },
  "required": [
    "event"
  ],
  "additionalProperties": false
}
Delivery
Server-sent event stream
Retry
Not declared idempotent
GET/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/images/{imageId}

Read an image referenced by a session event.

CLI
bento session image get --session-id example --image-id example
Scope
ws:{workspaceSlug}:sessions
Request
No JSON request body
Response
Raw byte stream
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/messages

Send a user message to a session

CLI
bento session message create --session-id example --prompt "..."
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "prompt": {
      "type": "string",
      "description": "The words of the input. May be empty when it carries images or attachments."
    },
    "clientRequestId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "images": {
      "maxItems": 4,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "minLength": 1
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp",
              "image/gif"
            ]
          }
        },
        "required": [
          "data",
          "mimeType"
        ]
      }
    },
    "attachments": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "mimeType": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "path",
          "name",
          "bytes"
        ]
      }
    },
    "dictated": {
      "description": "True when the words were transcribed from speech.",
      "type": "boolean"
    },
    "tier": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "behavior": {
      "default": "steer",
      "type": "string",
      "enum": [
        "steer",
        "follow_up"
      ]
    },
    "sourceSessionId": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "prompt"
  ]
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "delivery": {
      "type": "string",
      "enum": [
        "accepted",
        "queued"
      ]
    },
    "url": {
      "type": "string",
      "format": "uri"
    }
  },
  "required": [
    "ok",
    "delivery",
    "url"
  ],
  "additionalProperties": false
}
Delivery
Standard response
Retry
Not declared idempotent
POST/v1/workspaces/{workspaceSlug}/sessions/{sessionId}/messages/wait

Send a user message and wait for the submitted turn to finish

CLI
bento session message create --session-id example --prompt "..."
Scope
ws:{workspaceSlug}:sessions
Request
Request JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "prompt": {
      "type": "string",
      "description": "The words of the input. May be empty when it carries images or attachments."
    },
    "clientRequestId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "images": {
      "maxItems": 4,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "minLength": 1
          },
          "mimeType": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp",
              "image/gif"
            ]
          }
        },
        "required": [
          "data",
          "mimeType"
        ]
      }
    },
    "attachments": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "bytes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "mimeType": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "path",
          "name",
          "bytes"
        ]
      }
    },
    "dictated": {
      "description": "True when the words were transcribed from speech.",
      "type": "boolean"
    },
    "tier": {
      "type": "string",
      "enum": [
        "frontier",
        "balanced",
        "economy",
        "openai-frontier",
        "openai-max",
        "anthropic-frontier",
        "anthropic-max",
        "anthropic-balanced",
        "google-recommended",
        "google-balanced"
      ]
    },
    "behavior": {
      "default": "steer",
      "type": "string",
      "enum": [
        "steer",
        "follow_up"
      ]
    },
    "sourceSessionId": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "prompt",
    "clientRequestId"
  ]
}
Query
Query parameters JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "waitMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 720000
    }
  }
}
Response
Response JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "sessionId": {
          "type": "string",
          "minLength": 1
        },
        "inputSeq": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "cwd": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "pattern": "^[^\\u0000-\\u001f\\u007f]+$"
        },
        "terminal": {
          "type": "object",
          "properties": {
            "seq": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "event": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "turn_started"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "step"
                            },
                            "step": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning_delta"
                                    },
                                    "delta": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "delta"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "text"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "reasoning"
                                    },
                                    "text": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call_start"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "tool_call"
                                    },
                                    "toolName": {
                                      "type": "string"
                                    },
                                    "toolCallId": {
                                      "type": "string"
                                    },
                                    "input": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "isError": {
                                      "type": "boolean"
                                    },
                                    "output": {
                                      "type": "array",
                                      "items": {
                                        "oneOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "text"
                                              },
                                              "text": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "text"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "const": "image"
                                              },
                                              "data": {
                                                "type": "string"
                                              },
                                              "mimeType": {
                                                "type": "string"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "data",
                                              "mimeType"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "details": {}
                                  },
                                  "required": [
                                    "type",
                                    "toolName",
                                    "toolCallId",
                                    "isError"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "const": "system"
                                    },
                                    "message": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "message"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "step"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_started"
                            },
                            "task": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "tool",
                                    "subagent",
                                    "scheduled"
                                  ]
                                },
                                "name": {
                                  "type": "string"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "ownerScopeId": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "pattern": "^turn-\\d+$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^task:t\\d+$"
                                    }
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "scheduled",
                                    "completed",
                                    "failed",
                                    "stopped",
                                    "lost"
                                  ]
                                },
                                "startedAt": {
                                  "type": "number"
                                },
                                "wakeAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "id",
                                "kind",
                                "name",
                                "label",
                                "ownerScopeId",
                                "status",
                                "startedAt"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "task"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_output"
                            },
                            "taskId": {
                              "type": "string",
                              "pattern": "^t\\d+$"
                            },
                            "chunk": {
                              "type": "string"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "taskId",
                            "chunk"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "task_settled"
                            },
                            "settlement": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "completed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "result": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "result"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "failed"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "error": {}
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "error"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "stopped"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    },
                                    "reason": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt",
                                    "reason"
                                  ],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^t\\d+$"
                                    },
                                    "status": {
                                      "type": "string",
                                      "const": "lost"
                                    },
                                    "settledAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "status",
                                    "settledAt"
                                  ],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "settlement"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "heartbeat"
                            },
                            "timestamp": {
                              "type": "number"
                            },
                            "activeTaskIds": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "pattern": "^t\\d+$"
                              }
                            }
                          },
                          "required": [
                            "type",
                            "timestamp",
                            "activeTaskIds"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "todos"
                            },
                            "todos": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "in_progress",
                                      "completed",
                                      "failed"
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "content",
                                  "status"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "todos"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "follow_up_queue"
                            },
                            "followUpQueue": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "message": {
                                    "type": "string"
                                  },
                                  "images": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "data": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "data",
                                        "mimeType"
                                      ],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": [
                                  "message"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "type",
                            "followUpQueue"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "state_machine"
                            },
                            "stateMachine": {
                              "type": "object",
                              "properties": {
                                "definition": {
                                  "type": "object",
                                  "properties": {
                                    "name": {
                                      "type": "string"
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "states": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "prompt",
                                    "states"
                                  ],
                                  "additionalProperties": false
                                },
                                "prompt": {
                                  "type": "string"
                                },
                                "currentState": {
                                  "type": "string"
                                },
                                "currentInput": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "progress": {
                                  "type": "object",
                                  "properties": {
                                    "states": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "states"
                                  ],
                                  "additionalProperties": {}
                                },
                                "history": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  }
                                },
                                "terminal": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                "terminalAcknowledged": {
                                  "type": "boolean"
                                },
                                "createdAt": {
                                  "type": "number"
                                },
                                "updatedAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "definition",
                                "prompt",
                                "history",
                                "createdAt",
                                "updatedAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "stateMachine"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "memory"
                            },
                            "phase": {
                              "type": "string",
                              "enum": [
                                "observation",
                                "reflection"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "completed"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "observations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            },
                            "usageBumpedObservations": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              }
                            }
                          },
                          "required": [
                            "type",
                            "phase",
                            "status",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "usage"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "turnUsage",
                            "usageByModel",
                            "lastMessageUsage",
                            "effectiveContextWindow",
                            "contextWindowUsage"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "system"
                            },
                            "level": {
                              "type": "string",
                              "enum": [
                                "debug",
                                "info",
                                "warn",
                                "error"
                              ]
                            },
                            "message": {
                              "type": "string"
                            },
                            "providerRecovery": {
                              "type": "object",
                              "properties": {
                                "fromModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "fromRoute": {
                                  "type": "string",
                                  "enum": [
                                    "configured",
                                    "vercel",
                                    "unknown"
                                  ]
                                },
                                "toModel": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 256
                                },
                                "toRoute": {
                                  "type": "string",
                                  "const": "vercel"
                                },
                                "reason": {
                                  "type": "string",
                                  "enum": [
                                    "empty_response",
                                    "provider_error"
                                  ]
                                },
                                "status": {
                                  "type": "integer",
                                  "minimum": 100,
                                  "maximum": 599
                                }
                              },
                              "required": [
                                "fromModel",
                                "fromRoute",
                                "toModel",
                                "toRoute",
                                "reason"
                              ],
                              "additionalProperties": false
                            },
                            "metadata": {
                              "type": "object",
                              "properties": {
                                "code": {
                                  "type": "string",
                                  "enum": [
                                    "storage_full",
                                    "session_cwd_fallback",
                                    "bound_agent_root_unavailable",
                                    "relay_backlog",
                                    "runner_exited",
                                    "relay_undeliverable",
                                    "interrupt_undeliverable"
                                  ]
                                }
                              },
                              "required": [
                                "code"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "level",
                            "message"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "router_switch"
                            },
                            "tier": {
                              "type": "string"
                            },
                            "route": {
                              "type": "string"
                            },
                            "fromModel": {
                              "type": "string"
                            },
                            "toModel": {
                              "type": "string"
                            },
                            "thinkingLevel": {
                              "type": "string",
                              "enum": [
                                "minimal",
                                "low",
                                "medium",
                                "high",
                                "xhigh"
                              ]
                            },
                            "trigger": {
                              "type": "string",
                              "enum": [
                                "first_turn",
                                "new_task",
                                "idle",
                                "manual_compact",
                                "overflow",
                                "modality_switch",
                                "tier_change"
                              ]
                            },
                            "rationale": {
                              "type": "string"
                            },
                            "probabilities": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "number"
                              }
                            },
                            "visionFallback": {
                              "type": "boolean"
                            },
                            "origin": {
                              "type": "object",
                              "properties": {
                                "taskId": {
                                  "type": "string",
                                  "pattern": "^t\\d+$"
                                }
                              },
                              "required": [
                                "taskId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "tier",
                            "route",
                            "fromModel",
                            "toModel",
                            "thinkingLevel",
                            "trigger",
                            "visionFallback"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "complete"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed",
                                "failed",
                                "cancelled"
                              ]
                            },
                            "result": {
                              "type": "string"
                            },
                            "error": {
                              "type": "string"
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "properties": {
                                "systemPrompt": {
                                  "type": "number"
                                },
                                "messages": {
                                  "type": "number"
                                },
                                "localMemory": {
                                  "type": "number"
                                },
                                "globalMemory": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "systemPrompt",
                                "messages",
                                "localMemory",
                                "globalMemory"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "state",
                            "status"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "ask"
                            },
                            "state": {
                              "type": "object",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "running",
                                    "waiting_for_human",
                                    "sleeping",
                                    "interrupted",
                                    "completed",
                                    "failed",
                                    "cancelled"
                                  ]
                                },
                                "mode": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "const": "agent"
                                    },
                                    {
                                      "type": "string",
                                      "const": "auto"
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    }
                                  ]
                                },
                                "options": {
                                  "type": "object",
                                  "properties": {
                                    "model": {
                                      "type": "string"
                                    },
                                    "memoryModel": {
                                      "type": "string"
                                    },
                                    "thinkingLevel": {
                                      "type": "string",
                                      "enum": [
                                        "minimal",
                                        "low",
                                        "medium",
                                        "high",
                                        "xhigh"
                                      ]
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "agent": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "running",
                                        "waiting",
                                        "completed",
                                        "failed",
                                        "cancelled"
                                      ]
                                    },
                                    "messages": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "role": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "role"
                                        ],
                                        "additionalProperties": {}
                                      }
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "messages"
                                  ],
                                  "additionalProperties": false
                                },
                                "stateMachine": {
                                  "type": "object",
                                  "properties": {
                                    "definition": {
                                      "type": "object",
                                      "properties": {
                                        "name": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "states": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "name",
                                        "prompt",
                                        "states"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "prompt": {
                                      "type": "string"
                                    },
                                    "currentState": {
                                      "type": "string"
                                    },
                                    "currentInput": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "progress": {
                                      "type": "object",
                                      "properties": {
                                        "states": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {}
                                          }
                                        }
                                      },
                                      "required": [
                                        "states"
                                      ],
                                      "additionalProperties": {}
                                    },
                                    "history": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      }
                                    },
                                    "terminal": {
                                      "type": "object",
                                      "propertyNames": {
                                        "type": "string"
                                      },
                                      "additionalProperties": {}
                                    },
                                    "terminalAcknowledged": {
                                      "type": "boolean"
                                    },
                                    "createdAt": {
                                      "type": "number"
                                    },
                                    "updatedAt": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "definition",
                                    "prompt",
                                    "history",
                                    "createdAt",
                                    "updatedAt"
                                  ],
                                  "additionalProperties": false
                                },
                                "pendingStateTransition": {
                                  "type": "object",
                                  "properties": {
                                    "stateName": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "stateName"
                                  ],
                                  "additionalProperties": false
                                },
                                "todos": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "content": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "pending",
                                          "in_progress",
                                          "completed",
                                          "failed"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "content",
                                      "status"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "followUpQueue": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "message": {
                                        "type": "string"
                                      },
                                      "images": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "data": {
                                              "type": "string"
                                            },
                                            "mimeType": {
                                              "type": "string"
                                            }
                                          },
                                          "required": [
                                            "data",
                                            "mimeType"
                                          ],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "message"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "queuedCommands": {
                                  "type": "array",
                                  "items": {
                                    "oneOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "prompt"
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "message",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "answer"
                                          },
                                          "questions": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "question": {
                                                  "type": "string"
                                                },
                                                "header": {
                                                  "type": "string"
                                                },
                                                "options": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "description": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": [
                                                      "label"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                },
                                                "multiSelect": {
                                                  "type": "boolean"
                                                }
                                              },
                                              "required": [
                                                "question",
                                                "options"
                                              ],
                                              "additionalProperties": false
                                            }
                                          },
                                          "answers": {
                                            "type": "object",
                                            "propertyNames": {
                                              "type": "string"
                                            },
                                            "additionalProperties": {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            }
                                          },
                                          "behavior": {
                                            "type": "string",
                                            "enum": [
                                              "steer",
                                              "follow_up"
                                            ]
                                          },
                                          "message": {
                                            "type": "string"
                                          },
                                          "images": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "data": {
                                                  "type": "string"
                                                },
                                                "mimeType": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "data",
                                                "mimeType"
                                              ],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questions",
                                          "answers",
                                          "behavior"
                                        ],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "const": "wake"
                                          }
                                        },
                                        "required": [
                                          "type"
                                        ],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                },
                                "tasks": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string",
                                        "pattern": "^t\\d+$"
                                      },
                                      "kind": {
                                        "type": "string",
                                        "enum": [
                                          "tool",
                                          "subagent",
                                          "scheduled"
                                        ]
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "ownerScopeId": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "pattern": "^turn-\\d+$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^task:t\\d+$"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "type": "string",
                                        "enum": [
                                          "running",
                                          "scheduled",
                                          "completed",
                                          "failed",
                                          "stopped",
                                          "lost"
                                        ]
                                      },
                                      "startedAt": {
                                        "type": "number"
                                      },
                                      "wakeAt": {
                                        "type": "number"
                                      }
                                    },
                                    "required": [
                                      "id",
                                      "kind",
                                      "name",
                                      "label",
                                      "ownerScopeId",
                                      "status",
                                      "startedAt"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "taskOutputTails": {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  },
                                  "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "pendingLostTaskReminderTaskIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "pattern": "^t\\d+$"
                                  }
                                },
                                "nextTaskId": {
                                  "type": "number"
                                },
                                "wireGuardHorizon": {
                                  "type": "object",
                                  "properties": {
                                    "evictionHorizon": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "evictionHorizon"
                                  ],
                                  "additionalProperties": false
                                },
                                "routing": {
                                  "type": "object",
                                  "properties": {
                                    "saved": {
                                      "type": "object",
                                      "properties": {
                                        "tier": {
                                          "type": "string"
                                        },
                                        "route": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "tier",
                                        "route"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "compactedSinceLastMessage": {
                                      "type": "boolean"
                                    },
                                    "currentTask": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "status",
                                "mode",
                                "agent"
                              ],
                              "additionalProperties": false
                            },
                            "questions": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "header": {
                                    "type": "string"
                                  },
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "label": {
                                          "type": "string"
                                        },
                                        "description": {
                                          "type": "string"
                                        }
                                      },
                                      "required": [
                                        "label"
                                      ],
                                      "additionalProperties": false
                                    }
                                  },
                                  "multiSelect": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "question",
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "turnUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "usageByModel": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "model": {
                                    "type": "string"
                                  },
                                  "transport": {
                                    "type": "object",
                                    "properties": {
                                      "provider": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "duet-gateway",
                                              "vercel-ai-gateway",
                                              "openrouter"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "openai-codex",
                                              "github-copilot"
                                            ]
                                          }
                                        ]
                                      },
                                      "billing": {
                                        "type": "string",
                                        "enum": [
                                          "plan-covered",
                                          "metered"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "provider",
                                      "billing"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "usage": {
                                    "type": "object",
                                    "properties": {
                                      "input": {
                                        "type": "number"
                                      },
                                      "output": {
                                        "type": "number"
                                      },
                                      "cacheRead": {
                                        "type": "number"
                                      },
                                      "cacheWrite": {
                                        "type": "number"
                                      },
                                      "cacheWrite1h": {
                                        "type": "number"
                                      },
                                      "totalTokens": {
                                        "type": "number"
                                      },
                                      "cost": {
                                        "type": "object",
                                        "properties": {
                                          "input": {
                                            "type": "number"
                                          },
                                          "output": {
                                            "type": "number"
                                          },
                                          "cacheRead": {
                                            "type": "number"
                                          },
                                          "cacheWrite": {
                                            "type": "number"
                                          },
                                          "total": {
                                            "type": "number"
                                          }
                                        },
                                        "required": [
                                          "input",
                                          "output",
                                          "cacheRead",
                                          "cacheWrite",
                                          "total"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "required": [
                                      "input",
                                      "output",
                                      "cacheRead",
                                      "cacheWrite",
                                      "totalTokens",
                                      "cost"
                                    ],
                                    "additionalProperties": false
                                  }
                                },
                                "required": [
                                  "model",
                                  "transport",
                                  "usage"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "lastMessageUsage": {
                              "type": "object",
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                },
                                "cacheRead": {
                                  "type": "number"
                                },
                                "cacheWrite": {
                                  "type": "number"
                                },
                                "cacheWrite1h": {
                                  "type": "number"
                                },
                                "totalTokens": {
                                  "type": "number"
                                },
                                "cost": {
                                  "type": "object",
                                  "properties": {
                                    "input": {
                                      "type": "number"
                                    },
                                    "output": {
                                      "type": "number"
                                    },
                                    "cacheRead": {
                                      "type": "number"
                                    },
                                    "cacheWrite": {
                                      "type": "number"
                                    },
                                    "total": {
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "input",
                                    "output",
                                    "cacheRead",
                                    "cacheWrite",
                                    "total"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "input",
                                "output",
                                "cacheRead",
                                "cacheWrite",
                                "totalTokens",
                                "cost"
                              ],
                              "additionalProperties": false
                            },
                            "effectiveContextWindow": {
                              "type": "number"
                            },
                            "contextWindowUsage": {
                              "type": "object",
                              "proper