# AUTO-GENERATED tier-A mirror spec — do not edit.
# Source: openapi/runtime/activity.yaml (runtime 0.71.2)
#  + policy: openapi/mirror-policies/activity.json
# Regenerate: node scripts/generate-mirror-specs.mjs
openapi: 3.0.3
info:
  title: naturali.ai — Activity API
  version: 1.0.0
  description: >-
    Activity: what a project's agents actually did, newest first — one entry per executed action,
    resolved approval, raised exception and fired schedule, each with a one-line summary and the
    structured detail behind it. A fully runtime-backed module — this spec is generated verbatim
    from the runtime's own, re-rooted under /v1/projects/{project_id}. The project in the path is
    authorized by naturali and enforced upstream by the project's scoped credential.


    This module mirrors the upstream runtime verbatim (tier A, #304): paths are the runtime's own
    re-rooted under /v1/projects/{project_id}, and every field, method, status code and error shape
    passes through unchanged. Errors raised by the runtime arrive in its envelope; errors raised by
    naturali itself (authentication, project resolution, an unreachable runtime) use naturali's.
  contact:
    name: naturali.ai
    url: https://naturali.ai
servers:
  - url: "{baseUrl}"
    description: Host of your naturali.ai deployment; every path carries the /v1 prefix.
    variables:
      baseUrl:
        description: Base host URL.
        default: https://api.naturali.ai
tags:
  - name: Activity
    description: Read the autonomous-execution activity feed
security:
  - bearerAuth: []
  - oauth2:
      - mcp:access
paths:
  /v1/projects/{project_id}/activity:
    get:
      tags:
        - Activity
      summary: List activity feed entries
      description: Returns activity entries for a project, newest first, filterable by kind, severity,
        agent, generation and orchestration run — every filter composable with the rest. Paginated
        with an opaque cursor rather than offset/limit — pass the previous page's `next_cursor` to
        fetch the next one; a `null` `next_cursor` means there is no more data.
      operationId: listActivity
      parameters:
        - name: kind
          in: query
          description: Filter by activity kind
          schema:
            type: string
            enum:
              - action_executed
              - approval_created
              - approval_resolved
              - exception_created
              - schedule_fired
              - share_cap_exceeded
              - share_resumed
              - share_revoked
              - share_suspended
              - tool_resolution_failed
              - usage_quantity_invalid
        - name: severity
          in: query
          description: Filter by severity
          schema:
            type: string
            enum:
              - info
              - warning
              - critical
        - name: agent_id
          in: query
          description: Filter to entries produced by one agent. Composable with every other filter — entries
            carry one agent, one generation and one run, so naming two narrows to the rows where
            both hold.
          schema:
            type: string
            example: agent_V1StGXR8Z5jdHi6B
        - name: generation_id
          in: query
          description: "Filter to entries produced during one agent generation. This is what turns
            `tool_resolution_failed` from alertable into usable: the warning for a suspect turn is
            one query rather than a scan of the project's feed."
          schema:
            type: string
            example: gen_V1StGXR8Z5jdHi6B
        - name: orchestration_run_id
          in: query
          description: Filter to entries produced during one orchestration run.
          schema:
            type: string
            example: orch_run_V1StGXR8Z5jdHi
        - name: cursor
          in: query
          description: Opaque cursor from a previous page's `next_cursor`
          schema:
            type: string
        - name: limit
          in: query
          required: false
          description: Maximum number of results to return
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
      responses:
        "200":
          description: Page of activity entries
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - next_cursor
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ActivityEntry"
                  next_cursor:
                    type: string
                    nullable: true
                    description: Pass as `cursor` to fetch the next page; `null` when this is the last page
        "400":
          description: Malformed cursor
        "401":
          description: Unauthorized
        "403":
          description: Forbidden
        "500":
          description: Internal server error
    parameters:
      - $ref: "#/components/parameters/ProjectId"
  /v1/projects/{project_id}/activity/export:
    get:
      tags:
        - Activity
      summary: Export the activity feed as NDJSON
      description: "Streams a project's activity entries as newline-delimited JSON — one entry object per
        line, **oldest first**, where the feed itself reads newest first: a feed answers what just
        happened, and a file is read start to end. `project_id` is required: the export is
        per-project by design. Filters behave exactly as they do on the list endpoint."
      operationId: exportActivity
      x-mcp-exclude: true
      parameters:
        - name: kind
          in: query
          description: Only entries of this kind
          schema:
            type: string
        - name: severity
          in: query
          description: Only entries of this severity
          schema:
            type: string
        - name: agent_id
          in: query
          description: Only entries an agent produced
          schema:
            type: string
            example: agent_V1StGXR8Z5jdHi6B
        - name: generation_id
          in: query
          description: Only entries a generation produced
          schema:
            type: string
            example: gen_V1StGXR8Z5jdHi6B
        - name: orchestration_run_id
          in: query
          description: Only entries an orchestration run produced
          schema:
            type: string
            example: orch_run_V1StGXR8Z5jdHi6B
      responses:
        "200":
          description: A newline-delimited stream of activity entries. Each line is a JSON object with the
            same fields as `ActivityEntry`.
          content:
            application/x-ndjson:
              schema:
                type: string
        "400":
          description: "`project_id` is required"
        "401":
          description: Unauthorized
        "403":
          description: Forbidden
    parameters:
      - $ref: "#/components/parameters/ProjectId"
components:
  schemas:
    ActivityEntry:
      type: object
      properties:
        id:
          type: string
          example: acte_V1StGXR8Z5jdHi6B
        project_id:
          x-naturali-ref: projects
          type: string
        kind:
          type: string
          enum:
            - action_executed
            - approval_created
            - approval_resolved
            - exception_created
            - schedule_fired
            - share_cap_exceeded
            - share_resumed
            - share_revoked
            - share_suspended
            - tool_resolution_failed
            - usage_quantity_invalid
          description: How the entry was produced. `tool_resolution_failed` means a tool binding contributed
            no tool to the turn — its source could not be reached or refused the listing, or the
            listing was read and left nothing to attach — so the turn ran without it. The generation
            itself completes, carrying no error, so this is the only signal that it answered with
            fewer tools than it was configured to have. `share_suspended`, `share_resumed` and
            `share_revoked` land in a consumer project when the publisher of a share it accepted
            suspends, resumes or revokes it; `ref_id` is the share and `detail` names the resource
            and the publisher project. `share_cap_exceeded` lands in the consumer project when a
            call through a share it accepted is refused by the share's `cap`.
            `usage_quantity_invalid` lands in the project a tool call is metered in when a resource
            price row's `quantity` reads no finite number >= 0; `ref_id` is the tool.
        severity:
          type: string
          enum:
            - info
            - warning
            - critical
        summary:
          type: string
          description: One-line, human-readable description
        detail:
          type: object
          nullable: true
          description: Kind-specific structured context (tool, args digest, node id, guardrail policy version)
        orchestration_run_id:
          type: string
          nullable: true
          description: Originating orchestration run, if any
        agent_id:
          type: string
          nullable: true
          description: Associated agent, if any
        generation_id:
          type: string
          nullable: true
          description: The agent generation the entry was produced during, if any. Filter on it with the
            `generation_id` query parameter to read everything one turn did.
        ref_id:
          type: string
          nullable: true
          description: Producer-specific reference (the approval, exception, or trigger firing id the entry
            came from, or the executed tool's id)
        created_at:
          type: string
          format: date-time
  parameters:
    ProjectId:
      name: project_id
      in: path
      required: true
      description: Project public ID (proj_ prefix).
      schema:
        type: string
        example: proj_V1StGXR8Z5jdHi6B
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A naturali API key (nat_sk_…) or a session JWT.
    oauth2:
      type: oauth2
      description: "A connected app's OAuth access token, issued by this API's authorization server
        (discovery: /.well-known/oauth-authorization-server). Its one scope carries every operation,
        confined to the projects the user chose when approving the app."
      flows:
        authorizationCode:
          authorizationUrl: https://api.naturali.ai/authorize
          tokenUrl: https://api.naturali.ai/token
          refreshUrl: https://api.naturali.ai/token
          scopes:
            mcp:access: Every operation this API serves, on the projects the grant covers.
