{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/teamyou-com/json-schema/teamyou-com-agent-document-summary-schema.json",
  "title": "AgentDocumentSummary",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/teamyou-com-openapi.json#/components/schemas/AgentDocumentSummary",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "path": {
      "type": "string"
    },
    "byteSize": {
      "type": [
        "integer",
        "null"
      ]
    },
    "sharedBy": {
      "$ref": "#/$defs/SharedByUser",
      "description": "Present ONLY on a document another user shared with you (scope=shared or scope=all). Absent on your own documents — its presence is the signal that this document is not yours to overwrite, and that access ends when the owner revokes it. The path shown is the path in THEIR Agent Drive, not a path in yours."
    },
    "accessed": {
      "$ref": "#/$defs/AccessedLibraryEntry",
      "description": "Present ONLY on a library row (scope=accessed). Says whose document this is, how you got in, and which of your agents last opened it. Distinct from sharedBy on purpose: sharedBy means somebody chose to give you this document, while this can just as easily be a public link one of your agents followed, which its owner knows nothing about."
    },
    "contentType": {
      "type": "string",
      "description": "IANA media type. Always \"text/markdown\" today."
    },
    "createdByAgentId": {
      "type": [
        "string",
        "null"
      ]
    },
    "lastModifiedByAgentId": {
      "type": [
        "string",
        "null"
      ]
    },
    "archivedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "Structured metadata PARSED from the document's leading YAML front matter, refreshed on every write. Read-only and derived — there is no field to set it with, deliberately: the front-matter block in content is the single source, so a pull returns exactly the bytes that were pushed and there is no second channel to disagree with them. Write a block to attach metadata; remove the block and this goes back to null on the next write. null means the document has no front matter, or has a block that did not parse (unterminated, invalid YAML, or not a mapping) — the two are not distinguished. The body is stored untouched either way. Conventional keys, not enforced and not the only ones allowed: status, type, and tags (an array). Filter on any of them with the where parameter on GET /agent-drive and POST /search/documents."
    },
    "visibility": {
      "type": "string",
      "enum": [
        "private",
        "public",
        "authenticated"
      ],
      "description": "Who can open the document at its /agent-drive/{id} URL. READ-ONLY here: private is the default, and changing it is a separate, separately-scoped request — PUT /agent-drive/{id}/visibility with the share scope, or the owner in the web app. The write path neither accepts nor honours this field, so publishing is never a side effect of saving content."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "title",
    "path",
    "contentType",
    "visibility",
    "createdAt",
    "updatedAt"
  ],
  "$defs": {
    "AccessedLibraryEntry": {
      "type": "object",
      "properties": {
        "owner": {
          "$ref": "#/$defs/SharedByUser",
          "description": "The document's owner. Named because on somebody else's document, whose it is identifies it — not where it sits in their Agent Drive."
        },
        "via": {
          "type": "string",
          "enum": [
            "link",
            "grant"
          ],
          "description": "How you got in the last time you opened it. \"link\" covers both public and signed-in-only documents — from the reader's side they are one story, and the tier is the owner's to change at any moment. \"grant\" means the owner named you specifically."
        },
        "byAgent": {
          "type": [
            "string",
            "null"
          ],
          "description": "The agent that READ it most recently, by display name, or null when no agent has. Opening the document yourself no longer clears this: your own opens and your agents’ reads are tracked as separate channels, so both facts survive independently."
        },
        "firstAccessedAt": {
          "type": "string",
          "format": "date-time"
        },
        "lastAccessedAt": {
          "type": "string",
          "format": "date-time",
          "description": "The most recent access in EITHER channel — the sort key for this listing. Use the per-channel timestamps below to say WHO; this one only says when anything last happened."
        },
        "lastHumanAccessAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When YOU last opened it in a browser, or null if you never have (an agent may have read it without you looking)."
        },
        "humanAccessCount": {
          "type": "integer"
        },
        "lastAgentAccessAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When one of your agents last read it through the API, or null if none has. Independent of your own opens — reading it yourself does not reset or clear this."
        },
        "agentAccessCount": {
          "type": "integer"
        }
      },
      "required": [
        "owner",
        "via",
        "byAgent",
        "firstAccessedAt",
        "lastAccessedAt",
        "lastHumanAccessAt",
        "humanAccessCount",
        "lastAgentAccessAt",
        "agentAccessCount"
      ]
    },
    "SharedByUser": {
      "type": "object",
      "properties": {
        "userId": {
          "type": "string"
        },
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "The owner's display name, their email when no name is set, or null."
        }
      },
      "required": [
        "userId"
      ]
    }
  }
}