Starholder API
Operation Reference

Huelva

1 operation tagged huelva.

huelva_ask_or_followthrough

POST /api/v1/huelva

Ask Huelva without a room. Huelva's headless entry (AES §8.4.9). Runs one Huelva ask for the caller's owner with the API key or OAuth connection alone: a free-text user_message, or a structured follow-through on a known proposal, plan, or outcome. With worldId the ask is anchored on the owner's latest open non-room session in that world; without it Huelva works from her home advisory session. Either way she works across every world the owner owns or is a member of. Asking changes nothing in a world: an ask runs no staged work, including work Huelva would run at once in the app and an approval said in words. One staged action comes back as responseKind 'proposal' with a confirm action whose approveBody and rejectBody are this operation's own proposal_followthrough bodies; several come back as a plan in shell.result (kind 'plan', plan.planId), decided with a plan_followthrough body. shell.result.kind also tells an answer (resolution, whose citations carry the sourceRefs she relied on) from a clarification, a question the next user_message answers, and from honest_insufficiency. Name a world in userMessage by its handle (@owner/world) or send worldId; asks on the same anchor share its recent exchanges. The body is validated before authorization because huelvaAsk.kind names the policy: a user_message is authorized against huelva_ask (world:read, inference:propose), and every follow-through kind against huelva_followthrough, which also needs world:write. The confirm result is reported in fields: responseKind 'rejected' for a rejection, 'approval_status' for every other outcome (resolutionState, executionBridged, receiptRefs, failure), each with the world the proposal was staged for. Steps that run in the Starholder app (client settlements) are reported in shell.result, and responseText says so; nothing claims the caller carried them out. The same room-lane reply fields as chat_room_addons_huelva_ask_post. A user_message with a requestId that already committed replays the stored answer. A buffered call may run for minutes (maxDuration 800s); with Accept: text/event-stream the response becomes an SSE stream with a 770s run budget.

Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used). A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.

Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):

  • huelva_ask: callers external_agent; scopes world:read, inference:propose; mutation class none.
  • huelva_followthrough: callers external_agent; scopes world:read, inference:propose, world:write; mutation class none.

Parameters

NameInRequiredTypeDescription
x-origin-systemheaderyesstringRequired for external agents (AES §11.9); 422 without it. The MCP server sends mcp_http.
AcceptheadernostringContaining 'text/event-stream' selects the streaming transport.
X-Correlation-Idheadernostring

Request body (application/json, required)

{
  "type": "object",
  "required": [
    "huelvaAsk"
  ],
  "properties": {
    "huelvaAsk": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "kind",
            "userMessage"
          ],
          "properties": {
            "kind": {
              "const": "user_message"
            },
            "userMessage": {
              "type": "string",
              "minLength": 1
            },
            "requestId": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "kind",
            "proposalId",
            "requestedAction"
          ],
          "properties": {
            "kind": {
              "const": "proposal_followthrough"
            },
            "proposalId": {
              "type": "string",
              "minLength": 1
            },
            "requestedAction": {
              "enum": [
                "approve",
                "reject",
                "status",
                "retry_failed_remainder"
              ]
            },
            "requestId": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "kind",
            "planId",
            "requestedAction"
          ],
          "properties": {
            "kind": {
              "const": "plan_followthrough"
            },
            "planId": {
              "type": "string",
              "minLength": 1
            },
            "requestedAction": {
              "enum": [
                "approve",
                "reject",
                "status",
                "retry_failed_remainder"
              ]
            },
            "requestId": {
              "type": "string"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "kind",
            "outcomeRef"
          ],
          "properties": {
            "kind": {
              "const": "outcome_followthrough"
            },
            "outcomeRef": {
              "type": "string",
              "minLength": 1
            },
            "requestId": {
              "type": "string"
            }
          }
        }
      ]
    },
    "worldId": {
      "type": "string",
      "minLength": 1,
      "description": "The world the ask is about. Omitted, Huelva works from her home advisory session. A world the owner cannot read answers 404 before Huelva runs."
    },
    "requestId": {
      "type": "string",
      "description": "Source request id; huelvaAsk.requestId wins. Default 'huelva_api_<uuid>'. A repeated user_message with the same id replays the committed answer."
    },
    "requestIdentity": {
      "type": "object",
      "properties": {
        "workstreamId": {
          "type": "string",
          "minLength": 1
        },
        "sourceRevision": {
          "type": "integer",
          "minimum": 0
        },
        "ownerReadReplay": {
          "type": "object",
          "description": "Requires workstreamId. Required: evidenceSetDigest, capabilityRef, owner{kind: hub_flow(packageRef, flowId) | direct_owner(ownerFamily, executionClass consult|execute), operationRef, loweringRef}, subjectRef, subjectKind. Optional: flowId, query, lookupQuery, mode, subjectLabel, continuationFocusWorldId, asOfEventId, latestKnownEventId."
        }
      }
    },
    "researchActivation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode"
      ],
      "properties": {
        "mode": {
          "enum": [
            "ordinary_huelva",
            "clean_research"
          ]
        },
        "continuation": {
          "description": "Allowed only when mode is clean_research.",
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "kind"
              ],
              "properties": {
                "kind": {
                  "const": "open_or_retry"
                }
              }
            },
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "kind",
                "branchRef",
                "authority",
                "authorityEffect"
              ],
              "properties": {
                "kind": {
                  "const": "continue_branch"
                },
                "branchRef": {
                  "type": "string",
                  "minLength": 1
                },
                "continuedFromRunRef": {
                  "type": "string",
                  "minLength": 1
                },
                "authority": {
                  "const": "explicit_user_followup"
                },
                "authorityEffect": {
                  "enum": [
                    "control_only",
                    "user_amendment"
                  ]
                }
              }
            }
          ]
        }
      }
    },
    "stagedArtifactRevisionLineage": {
      "not": {},
      "description": "Retired; presence yields 400 input_invalid."
    }
  }
}

Responses

  • 200: HuelvaTransportEnvelope merged with the Huelva lane's response fields, the same fields the room lane returns. Also delivered as the body of the SSE 'settled' event.

    application/json

    {
      "allOf": [
        {
          "$ref": "#/components/schemas/HuelvaTransportEnvelope"
        },
        {
          "type": "object",
          "required": [
            "responseKind",
            "laneId",
            "responseText",
            "promptTranscript",
            "replyTranscript"
          ],
          "properties": {
            "status": {
              "const": "ok"
            },
            "checkedAt": {
              "type": "string"
            },
            "shell": {
              "type": "object",
              "description": "questionClass, ownerMap, stageAccounting, operatorHints?, prototype?, traceSummary, result: HuelvaShellResult"
            },
            "responseKind": {
              "enum": [
                "private_lane",
                "proposal",
                "rejected",
                "approval_status"
              ]
            },
            "laneId": {
              "const": "huelva"
            },
            "responseText": {
              "type": "string",
              "description": "The lane's reply. For rejected and approval_status it states the outcome in words, naming the proposal, its summary when known, and the resolved target world, so it agrees with resolutionState, executionBridged, receiptRefs, and failure."
            },
            "displayOnlyFields": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "responseText"
                ]
              },
              "description": "rejected and approval_status only: [\"responseText\"]. Those outcomes compose responseText from their fields, so it is the reply to show a person; a client decides what happened from resolutionState, executionBridged, receiptRefs, and failure, never from the prose (CHAT §2.8)."
            },
            "proposalId": {
              "type": "string",
              "description": "proposal, rejected, and approval_status"
            },
            "confirmPlaneId": {
              "const": "huelva.user_confirm",
              "description": "proposal only"
            },
            "expiresAt": {
              "type": [
                "string",
                "null"
              ],
              "description": "proposal only"
            },
            "decision": {
              "enum": [
                "approve",
                "reject"
              ],
              "description": "rejected and approval_status: the decision the confirm carried"
            },
            "requestedTargetRefs": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "proposal, rejected, and approval_status: the world refs the request named"
            },
            "resolvedTargetWorlds": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/ChatPrivateLaneResolvedTargetWorld"
              },
              "description": "proposal, rejected, and approval_status: the worlds the proposal was staged for, read from the stored proposal on a confirm"
            },
            "confirm": {
              "type": "object",
              "description": "proposal only: {method:'POST', path:'/api/v1/huelva', credentials:'same_as_request', approveBody:{huelvaAsk:{kind:'proposal_followthrough', proposalId, requestedAction:'approve'}}, rejectBody:{huelvaAsk:{... requestedAction:'reject'}}}"
            },
            "resolutionState": {
              "enum": [
                "rejected",
                "approved",
                "partially_completed",
                "bridge_failed",
                "pending_consensus",
                "pending_review",
                "superseded",
                null
              ],
              "description": "rejected: 'rejected'. approval_status: Huelva's recorded approval state; superseded cannot be resolved (stage the work again); null when Huelva stopped before deciding, with the reason in failure."
            },
            "executionBridged": {
              "type": "boolean",
              "description": "approval_status only: the approved work was handed to its owner"
            },
            "receiptRefs": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "approval_status only: receipts the executed steps recorded. approved with receipts means the action was carried out."
            },
            "failure": {
              "oneOf": [
                {
                  "type": "object",
                  "required": [
                    "code"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "stage": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                {
                  "type": "null"
                }
              ],
              "description": "approval_status only: why the approved work did not run (bridge failure or status error), or the reason Huelva stopped before deciding"
            },
            "promptTranscript": {
              "const": "private"
            },
            "replyTranscript": {
              "const": "private"
            }
          }
        }
      ]
    }
  • 400: {status:'error', error:'input_invalid', message} for a missing, invalid, or unsupported huelvaAsk, an invalid worldId, requestIdentity, or researchActivation, or a retired field (an invalid JSON body is treated as {}). The body is validated before authorization, so an unauthenticated caller can receive 400. {status:'error', error:{code:'proposal_expired', message, proposalId, resolutionState:'expired', requestedTargetRefs?, resolvedTargetWorlds?}} for an expired follow-through. Shell failures without retryAfterMs, including huelva_invocation_claim_conflict for a requestId reused with a different ask: {status:'error', error:<failureCode>, failureClass:'owner_handoff_failure'|'shell_failure', message}.

    application/json

    {
      "type": "object",
      "properties": {
        "status": {
          "const": "error"
        },
        "error": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "proposalId": {
                  "type": "string",
                  "description": "proposal_expired only"
                },
                "resolutionState": {
                  "const": "expired",
                  "description": "proposal_expired only"
                },
                "requestedTargetRefs": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "proposal_expired only"
                },
                "resolvedTargetWorlds": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChatPrivateLaneResolvedTargetWorld"
                  },
                  "description": "proposal_expired only"
                }
              }
            }
          ]
        },
        "failureClass": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  • 401: No credential and no signed-in session: middleware answers { "error": "unauthorized" } before the route runs. A credential that fails validation: ERR_AUTH_INVALID in the error envelope.

    application/json

    {
      "oneOf": [
        {
          "$ref": "#/components/schemas/AesErrorEnvelope"
        },
        {
          "type": "object",
          "required": [
            "error"
          ],
          "properties": {
            "error": {
              "const": "unauthorized"
            }
          }
        }
      ]
    }
  • 403: Authorization denial in the AES error envelope. A follow-through without world:write answers ERR_PERMISSION_INTERSECTION_DENIED with details {reason:'missing_scope', detail:'world:write'} before anything runs.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 404: ERR_WORLD_NOT_FOUND: worldId names a world that does not exist or that the owner cannot read. Error codes: ERR_WORLD_NOT_FOUND.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 409: Shell or owner-handoff failure carrying retryAfterMs, such as a repeated requestId whose first ask is still running.

    application/json

    {
      "type": "object",
      "properties": {
        "status": {
          "const": "error"
        },
        "error": {
          "type": "string"
        },
        "failureClass": {
          "enum": [
            "owner_handoff_failure",
            "shell_failure"
          ]
        },
        "message": {
          "type": "string"
        },
        "retryAfterMs": {
          "type": "integer",
          "minimum": 0
        }
      }
    }
  • 422: ERR_VALIDATION_FAILED: missing x-origin-system for an external agent. Error codes: ERR_VALIDATION_FAILED.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 429: ERR_QUOTA_EXCEEDED with Retry-After. A user_message counts against the inference quota. Error codes: ERR_QUOTA_EXCEEDED.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 500: ERR_INTERNAL in the AES error envelope. Streaming wrapper failures appear as settled {httpStatus:500, body:{status:'error', error:'huelva_ask_stream_failed', message}}. Error codes: ERR_INTERNAL.

    application/json

    {
      "oneOf": [
        {
          "$ref": "#/components/schemas/ApiErrorEnvelope"
        },
        {
          "type": "object",
          "properties": {
            "status": {
              "const": "error"
            },
            "error": {
              "const": "huelva_ask_stream_failed"
            },
            "message": {
              "type": "string"
            }
          }
        }
      ]
    }
  • 502: Prototype terminal failure.

    application/json

    {
      "type": "object",
      "properties": {
        "status": {
          "const": "error"
        },
        "error": {
          "type": "string"
        },
        "failureClass": {
          "const": "prototype_terminal_failure"
        },
        "message": {
          "type": "string"
        },
        "retryable": {
          "type": "boolean"
        },
        "prototypePartialTrace": {
          "type": "object"
        }
      }
    }
  • 504: Streaming transport only (inside 'settled'): run budget exhausted.

    application/json

    {
      "type": "object",
      "properties": {
        "status": {
          "const": "error"
        },
        "error": {
          "const": "huelva_ask_run_budget_exhausted"
        },
        "failureClass": {
          "const": "run_budget_exhausted"
        },
        "message": {
          "type": "string"
        }
      }
    }

Server-sent events

Accept header contains 'text/event-stream'. Input validation, authorization, the origin header, quota, and the world check answer first as plain HTTP responses; once they pass, the stream opens and every outcome (including Huelva's 400, 409, 502, and 504) is delivered in the terminal 'settled' event while the HTTP status is 200. Content-Type: text/event-stream; charset=utf-8; Cache-Control: no-cache, no-transform; X-Accel-Buffering: no.

EventData
(comment)Initial ': ok' comment; then ': huelva-ask-keepalive' comment every 10s before each ping.
openSent immediately.
pingEvery 10s.
progressAdvisory research-loop progress. (HuelvaPrototypeProgressNotice)
settledTerminal. The exact HTTP status and JSON body the buffered transport would have returned. The stream then closes.

Resume: None. No SSE id fields are emitted and Last-Event-ID is not read. A reconnect re-POSTs a new ask.

Schemas used: #/components/responses/Forbidden, #/components/responses/Unauthenticated, ApiErrorEnvelope, ChatPrivateLaneResolvedTargetWorld, HuelvaPrototypeProgressNotice, HuelvaTransportEnvelope

Contract authored from app/api/v1/huelva/route.ts (confidence: high).