/* tslint:disable */
/* eslint-disable */
/**
 * Fabro Run API
 * HTTP API for managing Fabro workflow run executions.
 *
 * The version of the OpenAPI document: 0.2.0
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction, replaceWithSerializableTypeIfNeeded } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { AppendEventResponse } from '../models';
// @ts-ignore
import type { ArtifactListResponse } from '../models';
// @ts-ignore
import type { CommandLogResponse } from '../models';
// @ts-ignore
import type { ErrorResponse } from '../models';
// @ts-ignore
import type { PaginatedEventList } from '../models';
// @ts-ignore
import type { PaginatedRunStageList } from '../models';
// @ts-ignore
import type { RunArtifactListResponse } from '../models';
// @ts-ignore
import type { RunCheckpoint } from '../models';
// @ts-ignore
import type { RunEvent } from '../models';
// @ts-ignore
import type { RunEventDetailResponse } from '../models';
// @ts-ignore
import type { RunProjection } from '../models';
// @ts-ignore
import type { StageContextWindow } from '../models';
// @ts-ignore
import type { WorkflowSettings } from '../models';
// @ts-ignore
import type { WriteBlobResponse } from '../models';
// @ts-ignore
import type { WriteRunBlobRequest } from '../models';
/**
 * RunInternalsApi - axios parameter creator
 */
export const RunInternalsApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
        /**
         * Appends a validated event to the run event log. Intended for trusted internal callers.
         * @summary Append Run Event
         * @param {string} id Unique run identifier (ULID).
         * @param {RunEvent} runEvent
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        appendRunEvent: async (id: string, runEvent: RunEvent, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('appendRunEvent', 'id', id)
            // verify required parameter 'runEvent' is not null or undefined
            assertParamExists('appendRunEvent', 'runEvent', runEvent)
            const localVarPath = `/api/v1/runs/{id}/events`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Content-Type'] = 'application/json';
            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(runEvent, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Opens an ordered server-sent event stream starting at `since_seq`, replaying persisted events and continuing with live updates while the run remains active.
         * @summary Attach Run Events
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        attachRunEvents: async (id: string, sinceSeq?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('attachRunEvents', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/attach`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (sinceSeq !== undefined) {
                localVarQueryParameter['since_seq'] = sinceSeq;
            }

            localVarHeaderParameter['Accept'] = 'text/event-stream,application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Streams a ZIP archive with the latest captured version of each artifact path. Stage order, retry number, and then stage ID determine the latest version, matching the artifacts page. Captures from the graph\'s boundary nodes are excluded, identified by their `start` and `exit` handler type rather than by node name.  The archive streams, so the response status is sent before the first artifact is read. A failure after that point aborts the transfer rather than returning `500`. The ZIP central directory is written last, so a truncated download does not open as a valid archive.
         * @summary Download Run Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        downloadRunArtifacts: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('downloadRunArtifacts', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/artifacts/download`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/zip,application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns one stored run event by source event sequence with content fields separated and truncated.
         * @summary Get Run Event Detail
         * @param {string} id Unique run identifier (ULID).
         * @param {number} seq
         * @param {number} [maxContentLength]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunEventDetail: async (id: string, seq: number, maxContentLength?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('getRunEventDetail', 'id', id)
            // verify required parameter 'seq' is not null or undefined
            assertParamExists('getRunEventDetail', 'seq', seq)
            const localVarPath = `/api/v1/runs/{id}/events/{seq}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"seq"}}`, encodeURIComponent(String(seq)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (maxContentLength !== undefined) {
                localVarQueryParameter['max_content_length'] = maxContentLength;
            }

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns the worker tracing log for a run when it is available.
         * @summary Get Run Logs
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunLogs: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('getRunLogs', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/logs`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'text/plain; charset=utf-8,application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns a byte-offset slice of a command stage output log. Bytes are base64-encoded and are not snapped to UTF-8 boundaries.
         * @summary Tail Command Log
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} [offset] Byte offset to start reading from. Defaults to &#x60;0&#x60;.
         * @param {number} [limit] Maximum bytes to return. Defaults to 65536 and is capped at 1048576.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunStageCommandLog: async (id: string, stageId: string, offset?: number, limit?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('getRunStageCommandLog', 'id', id)
            // verify required parameter 'stageId' is not null or undefined
            assertParamExists('getRunStageCommandLog', 'stageId', stageId)
            const localVarPath = `/api/v1/runs/{id}/stages/{stageId}/logs/output`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"stageId"}}`, encodeURIComponent(String(stageId)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (offset !== undefined) {
                localVarQueryParameter['offset'] = offset;
            }

            if (limit !== undefined) {
                localVarQueryParameter['limit'] = limit;
            }

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns the latest best-effort model-visible context-window usage snapshot for an agent stage. Known stages without applicable or observed data return `available: false`; missing runs or stages return 404.
         * @summary Get Stage Context Window
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunStageContextWindow: async (id: string, stageId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('getRunStageContextWindow', 'id', id)
            // verify required parameter 'stageId' is not null or undefined
            assertParamExists('getRunStageContextWindow', 'stageId', stageId)
            const localVarPath = `/api/v1/runs/{id}/stages/{stageId}/context-window`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"stageId"}}`, encodeURIComponent(String(stageId)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns the internal event-sourced run projection. This is not a stable public contract.
         * @summary Get Run State
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunState: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('getRunState', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/state`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Downloads an artifact by filename.
         * @summary Get Stage Artifact
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {string} filename Relative artifact path. &#x60;/&#x60; is allowed as a path separator. Backslash, empty segments, and traversal segments (&#x60;.&#x60; and &#x60;..&#x60;) are invalid.
         * @param {number} retry Retry attempt number for the artifact.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getStageArtifact: async (id: string, stageId: string, filename: string, retry: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('getStageArtifact', 'id', id)
            // verify required parameter 'stageId' is not null or undefined
            assertParamExists('getStageArtifact', 'stageId', stageId)
            // verify required parameter 'filename' is not null or undefined
            assertParamExists('getStageArtifact', 'filename', filename)
            // verify required parameter 'retry' is not null or undefined
            assertParamExists('getStageArtifact', 'retry', retry)
            const localVarPath = `/api/v1/runs/{id}/stages/{stageId}/artifacts/download`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"stageId"}}`, encodeURIComponent(String(stageId)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (filename !== undefined) {
                localVarQueryParameter['filename'] = filename;
            }

            if (retry !== undefined) {
                localVarQueryParameter['retry'] = retry;
            }

            localVarHeaderParameter['Accept'] = 'application/octet-stream,application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Lists captured artifact files for a run.
         * @summary List Run Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRunArtifacts: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('listRunArtifacts', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/artifacts`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns a paginated JSON list of stored run events. Ascending order uses `since_seq` as an inclusive cursor. Descending order uses `before_seq` as an exclusive cursor and starts at the newest event when `before_seq` is omitted.
         * @summary List Run Events
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {number} [limit] Maximum number of events to return.
         * @param {number} [beforeSeq] Exclusive upper event sequence cursor for descending order. Omit on the first descending request to start from the newest event.
         * @param {ListRunEventsOrderEnum} [order] Event sequence order. &#x60;since_seq&#x60; is valid only with &#x60;asc&#x60;; &#x60;before_seq&#x60; is valid only with &#x60;desc&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRunEvents: async (id: string, sinceSeq?: number, limit?: number, beforeSeq?: number, order?: ListRunEventsOrderEnum, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('listRunEvents', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/events`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (sinceSeq !== undefined) {
                localVarQueryParameter['since_seq'] = sinceSeq;
            }

            if (limit !== undefined) {
                localVarQueryParameter['limit'] = limit;
            }

            if (beforeSeq !== undefined) {
                localVarQueryParameter['before_seq'] = beforeSeq;
            }

            if (order !== undefined) {
                localVarQueryParameter['order'] = order;
            }

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns the ordered list of stages in a run\'s workflow graph with their current status and timing. Stages are bounded by the workflow graph size, typically fewer than 20.
         * @summary List Run Stages
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [pageLimit] Maximum number of items to return per page.
         * @param {number} [pageOffset] Number of items to skip before returning results.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRunStages: async (id: string, pageLimit?: number, pageOffset?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('listRunStages', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/stages`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (pageLimit !== undefined) {
                localVarQueryParameter['page[limit]'] = pageLimit;
            }

            if (pageOffset !== undefined) {
                localVarQueryParameter['page[offset]'] = pageOffset;
            }

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Lists artifact filenames stored for a stage.
         * @summary List Stage Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listStageArtifacts: async (id: string, stageId: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('listStageArtifacts', 'id', id)
            // verify required parameter 'stageId' is not null or undefined
            assertParamExists('listStageArtifacts', 'stageId', stageId)
            const localVarPath = `/api/v1/runs/{id}/stages/{stageId}/artifacts`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"stageId"}}`, encodeURIComponent(String(stageId)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns a paginated JSON list of stored run events scoped to a single stage visit.
         * @summary List Stage Events
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {number} [limit] Maximum number of events to return.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listStageEvents: async (id: string, stageId: string, sinceSeq?: number, limit?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('listStageEvents', 'id', id)
            // verify required parameter 'stageId' is not null or undefined
            assertParamExists('listStageEvents', 'stageId', stageId)
            const localVarPath = `/api/v1/runs/{id}/stages/{stageId}/events`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"stageId"}}`, encodeURIComponent(String(stageId)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (sinceSeq !== undefined) {
                localVarQueryParameter['since_seq'] = sinceSeq;
            }

            if (limit !== undefined) {
                localVarQueryParameter['limit'] = limit;
            }

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Uploads one or more artifacts for a stage. Intended for trusted internal callers.  The server accepts both: - `application/octet-stream` for single-file uploads with the `filename` query parameter - strict manifest-first `multipart/form-data` uploads documented by `ArtifactBatchUploadManifest`  The generated Rust client currently exposes the octet-stream variant because the OpenAPI code generator in this repo does not support multiple request media types on one operation.
         * @summary Put Stage Artifact
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} retry Retry attempt number for the artifact.
         * @param {File} body
         * @param {string} [filename] Relative artifact path for &#x60;application/octet-stream&#x60; uploads. Ignored for multipart uploads.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        putStageArtifact: async (id: string, stageId: string, retry: number, body: File, filename?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('putStageArtifact', 'id', id)
            // verify required parameter 'stageId' is not null or undefined
            assertParamExists('putStageArtifact', 'stageId', stageId)
            // verify required parameter 'retry' is not null or undefined
            assertParamExists('putStageArtifact', 'retry', retry)
            // verify required parameter 'body' is not null or undefined
            assertParamExists('putStageArtifact', 'body', body)
            const localVarPath = `/api/v1/runs/{id}/stages/{stageId}/artifacts`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"stageId"}}`, encodeURIComponent(String(stageId)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            if (retry !== undefined) {
                localVarQueryParameter['retry'] = retry;
            }

            if (filename !== undefined) {
                localVarQueryParameter['filename'] = filename;
            }

            localVarHeaderParameter['Content-Type'] = 'application/octet-stream';
            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Reads a previously stored blob by hash.
         * @summary Read Run Blob
         * @param {string} id Unique run identifier (ULID).
         * @param {string} blobHash Content-addressed blob hash.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        readRunBlob: async (id: string, blobHash: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('readRunBlob', 'id', id)
            // verify required parameter 'blobHash' is not null or undefined
            assertParamExists('readRunBlob', 'blobHash', blobHash)
            const localVarPath = `/api/v1/runs/{id}/blobs/{blobHash}`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)))
                .replace(`{${"blobHash"}}`, encodeURIComponent(String(blobHash)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/octet-stream,application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns the latest checkpoint data for a run, or null if no checkpoint has been recorded yet.
         * @summary Retrieve Run Checkpoint
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        retrieveRunCheckpoint: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('retrieveRunCheckpoint', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/checkpoint`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Returns the persisted dense `WorkflowSettings` snapshot used to launch this run.
         * @summary Retrieve Run Settings
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        retrieveRunSettings: async (id: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('retrieveRunSettings', 'id', id)
            const localVarPath = `/api/v1/runs/{id}/settings`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
        /**
         * Writes an opaque binary blob and returns its content-addressed blob hash.
         * @summary Write Run Blob
         * @param {string} id Unique run identifier (ULID).
         * @param {File} body
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        writeRunBlob: async (id: string, body: File, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
            // verify required parameter 'id' is not null or undefined
            assertParamExists('writeRunBlob', 'id', id)
            // verify required parameter 'body' is not null or undefined
            assertParamExists('writeRunBlob', 'body', body)
            const localVarPath = `/api/v1/runs/{id}/blobs`
                .replace(`{${"id"}}`, encodeURIComponent(String(id)));
            // use dummy base URL string because the URL constructor only accepts absolute URLs.
            const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
            let baseOptions;
            if (configuration) {
                baseOptions = configuration.baseOptions;
            }

            const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
            const localVarHeaderParameter = {} as any;
            const localVarQueryParameter = {} as any;

            // authentication SessionCookie required

            // authentication BearerAuth required
            // http bearer authentication required
            await setBearerAuthToObject(localVarHeaderParameter, configuration)

            localVarHeaderParameter['Content-Type'] = 'application/octet-stream';
            localVarHeaderParameter['Accept'] = 'application/json';

            setSearchParams(localVarUrlObj, localVarQueryParameter);
            let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
            localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
            localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)

            return {
                url: toPathString(localVarUrlObj),
                options: localVarRequestOptions,
            };
        },
    }
};

/**
 * RunInternalsApi - functional programming interface
 */
export const RunInternalsApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = RunInternalsApiAxiosParamCreator(configuration)
    return {
        /**
         * Appends a validated event to the run event log. Intended for trusted internal callers.
         * @summary Append Run Event
         * @param {string} id Unique run identifier (ULID).
         * @param {RunEvent} runEvent
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async appendRunEvent(id: string, runEvent: RunEvent, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AppendEventResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.appendRunEvent(id, runEvent, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.appendRunEvent']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Opens an ordered server-sent event stream starting at `since_seq`, replaying persisted events and continuing with live updates while the run remains active.
         * @summary Attach Run Events
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async attachRunEvents(id: string, sinceSeq?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.attachRunEvents(id, sinceSeq, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.attachRunEvents']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Streams a ZIP archive with the latest captured version of each artifact path. Stage order, retry number, and then stage ID determine the latest version, matching the artifacts page. Captures from the graph\'s boundary nodes are excluded, identified by their `start` and `exit` handler type rather than by node name.  The archive streams, so the response status is sent before the first artifact is read. A failure after that point aborts the transfer rather than returning `500`. The ZIP central directory is written last, so a truncated download does not open as a valid archive.
         * @summary Download Run Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async downloadRunArtifacts(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<File>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.downloadRunArtifacts(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.downloadRunArtifacts']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns one stored run event by source event sequence with content fields separated and truncated.
         * @summary Get Run Event Detail
         * @param {string} id Unique run identifier (ULID).
         * @param {number} seq
         * @param {number} [maxContentLength]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getRunEventDetail(id: string, seq: number, maxContentLength?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RunEventDetailResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getRunEventDetail(id, seq, maxContentLength, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.getRunEventDetail']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the worker tracing log for a run when it is available.
         * @summary Get Run Logs
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getRunLogs(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getRunLogs(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.getRunLogs']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns a byte-offset slice of a command stage output log. Bytes are base64-encoded and are not snapped to UTF-8 boundaries.
         * @summary Tail Command Log
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} [offset] Byte offset to start reading from. Defaults to &#x60;0&#x60;.
         * @param {number} [limit] Maximum bytes to return. Defaults to 65536 and is capped at 1048576.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getRunStageCommandLog(id: string, stageId: string, offset?: number, limit?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommandLogResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getRunStageCommandLog(id, stageId, offset, limit, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.getRunStageCommandLog']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the latest best-effort model-visible context-window usage snapshot for an agent stage. Known stages without applicable or observed data return `available: false`; missing runs or stages return 404.
         * @summary Get Stage Context Window
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getRunStageContextWindow(id: string, stageId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<StageContextWindow>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getRunStageContextWindow(id, stageId, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.getRunStageContextWindow']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the internal event-sourced run projection. This is not a stable public contract.
         * @summary Get Run State
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getRunState(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RunProjection>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getRunState(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.getRunState']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Downloads an artifact by filename.
         * @summary Get Stage Artifact
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {string} filename Relative artifact path. &#x60;/&#x60; is allowed as a path separator. Backslash, empty segments, and traversal segments (&#x60;.&#x60; and &#x60;..&#x60;) are invalid.
         * @param {number} retry Retry attempt number for the artifact.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async getStageArtifact(id: string, stageId: string, filename: string, retry: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<File>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.getStageArtifact(id, stageId, filename, retry, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.getStageArtifact']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Lists captured artifact files for a run.
         * @summary List Run Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listRunArtifacts(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RunArtifactListResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listRunArtifacts(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.listRunArtifacts']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns a paginated JSON list of stored run events. Ascending order uses `since_seq` as an inclusive cursor. Descending order uses `before_seq` as an exclusive cursor and starts at the newest event when `before_seq` is omitted.
         * @summary List Run Events
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {number} [limit] Maximum number of events to return.
         * @param {number} [beforeSeq] Exclusive upper event sequence cursor for descending order. Omit on the first descending request to start from the newest event.
         * @param {ListRunEventsOrderEnum} [order] Event sequence order. &#x60;since_seq&#x60; is valid only with &#x60;asc&#x60;; &#x60;before_seq&#x60; is valid only with &#x60;desc&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listRunEvents(id: string, sinceSeq?: number, limit?: number, beforeSeq?: number, order?: ListRunEventsOrderEnum, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedEventList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listRunEvents(id, sinceSeq, limit, beforeSeq, order, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.listRunEvents']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the ordered list of stages in a run\'s workflow graph with their current status and timing. Stages are bounded by the workflow graph size, typically fewer than 20.
         * @summary List Run Stages
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [pageLimit] Maximum number of items to return per page.
         * @param {number} [pageOffset] Number of items to skip before returning results.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listRunStages(id: string, pageLimit?: number, pageOffset?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedRunStageList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listRunStages(id, pageLimit, pageOffset, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.listRunStages']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Lists artifact filenames stored for a stage.
         * @summary List Stage Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listStageArtifacts(id: string, stageId: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ArtifactListResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listStageArtifacts(id, stageId, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.listStageArtifacts']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns a paginated JSON list of stored run events scoped to a single stage visit.
         * @summary List Stage Events
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {number} [limit] Maximum number of events to return.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async listStageEvents(id: string, stageId: string, sinceSeq?: number, limit?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<PaginatedEventList>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.listStageEvents(id, stageId, sinceSeq, limit, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.listStageEvents']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Uploads one or more artifacts for a stage. Intended for trusted internal callers.  The server accepts both: - `application/octet-stream` for single-file uploads with the `filename` query parameter - strict manifest-first `multipart/form-data` uploads documented by `ArtifactBatchUploadManifest`  The generated Rust client currently exposes the octet-stream variant because the OpenAPI code generator in this repo does not support multiple request media types on one operation.
         * @summary Put Stage Artifact
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} retry Retry attempt number for the artifact.
         * @param {File} body
         * @param {string} [filename] Relative artifact path for &#x60;application/octet-stream&#x60; uploads. Ignored for multipart uploads.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async putStageArtifact(id: string, stageId: string, retry: number, body: File, filename?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.putStageArtifact(id, stageId, retry, body, filename, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.putStageArtifact']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Reads a previously stored blob by hash.
         * @summary Read Run Blob
         * @param {string} id Unique run identifier (ULID).
         * @param {string} blobHash Content-addressed blob hash.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async readRunBlob(id: string, blobHash: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<File>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.readRunBlob(id, blobHash, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.readRunBlob']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the latest checkpoint data for a run, or null if no checkpoint has been recorded yet.
         * @summary Retrieve Run Checkpoint
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async retrieveRunCheckpoint(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RunCheckpoint>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveRunCheckpoint(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.retrieveRunCheckpoint']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Returns the persisted dense `WorkflowSettings` snapshot used to launch this run.
         * @summary Retrieve Run Settings
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async retrieveRunSettings(id: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<WorkflowSettings>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.retrieveRunSettings(id, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.retrieveRunSettings']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
        /**
         * Writes an opaque binary blob and returns its content-addressed blob hash.
         * @summary Write Run Blob
         * @param {string} id Unique run identifier (ULID).
         * @param {File} body
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async writeRunBlob(id: string, body: File, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<WriteBlobResponse>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.writeRunBlob(id, body, options);
            const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
            const localVarOperationServerBasePath = operationServerMap['RunInternalsApi.writeRunBlob']?.[localVarOperationServerIndex]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
        },
    }
};

/**
 * RunInternalsApi - factory interface
 */
export const RunInternalsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
    const localVarFp = RunInternalsApiFp(configuration)
    return {
        /**
         * Appends a validated event to the run event log. Intended for trusted internal callers.
         * @summary Append Run Event
         * @param {string} id Unique run identifier (ULID).
         * @param {RunEvent} runEvent
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        appendRunEvent(id: string, runEvent: RunEvent, options?: RawAxiosRequestConfig): AxiosPromise<AppendEventResponse> {
            return localVarFp.appendRunEvent(id, runEvent, options).then((request) => request(axios, basePath));
        },
        /**
         * Opens an ordered server-sent event stream starting at `since_seq`, replaying persisted events and continuing with live updates while the run remains active.
         * @summary Attach Run Events
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        attachRunEvents(id: string, sinceSeq?: number, options?: RawAxiosRequestConfig): AxiosPromise<string> {
            return localVarFp.attachRunEvents(id, sinceSeq, options).then((request) => request(axios, basePath));
        },
        /**
         * Streams a ZIP archive with the latest captured version of each artifact path. Stage order, retry number, and then stage ID determine the latest version, matching the artifacts page. Captures from the graph\'s boundary nodes are excluded, identified by their `start` and `exit` handler type rather than by node name.  The archive streams, so the response status is sent before the first artifact is read. A failure after that point aborts the transfer rather than returning `500`. The ZIP central directory is written last, so a truncated download does not open as a valid archive.
         * @summary Download Run Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        downloadRunArtifacts(id: string, options?: RawAxiosRequestConfig): AxiosPromise<File> {
            return localVarFp.downloadRunArtifacts(id, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns one stored run event by source event sequence with content fields separated and truncated.
         * @summary Get Run Event Detail
         * @param {string} id Unique run identifier (ULID).
         * @param {number} seq
         * @param {number} [maxContentLength]
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunEventDetail(id: string, seq: number, maxContentLength?: number, options?: RawAxiosRequestConfig): AxiosPromise<RunEventDetailResponse> {
            return localVarFp.getRunEventDetail(id, seq, maxContentLength, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the worker tracing log for a run when it is available.
         * @summary Get Run Logs
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunLogs(id: string, options?: RawAxiosRequestConfig): AxiosPromise<string> {
            return localVarFp.getRunLogs(id, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns a byte-offset slice of a command stage output log. Bytes are base64-encoded and are not snapped to UTF-8 boundaries.
         * @summary Tail Command Log
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} [offset] Byte offset to start reading from. Defaults to &#x60;0&#x60;.
         * @param {number} [limit] Maximum bytes to return. Defaults to 65536 and is capped at 1048576.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunStageCommandLog(id: string, stageId: string, offset?: number, limit?: number, options?: RawAxiosRequestConfig): AxiosPromise<CommandLogResponse> {
            return localVarFp.getRunStageCommandLog(id, stageId, offset, limit, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the latest best-effort model-visible context-window usage snapshot for an agent stage. Known stages without applicable or observed data return `available: false`; missing runs or stages return 404.
         * @summary Get Stage Context Window
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunStageContextWindow(id: string, stageId: string, options?: RawAxiosRequestConfig): AxiosPromise<StageContextWindow> {
            return localVarFp.getRunStageContextWindow(id, stageId, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the internal event-sourced run projection. This is not a stable public contract.
         * @summary Get Run State
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getRunState(id: string, options?: RawAxiosRequestConfig): AxiosPromise<RunProjection> {
            return localVarFp.getRunState(id, options).then((request) => request(axios, basePath));
        },
        /**
         * Downloads an artifact by filename.
         * @summary Get Stage Artifact
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {string} filename Relative artifact path. &#x60;/&#x60; is allowed as a path separator. Backslash, empty segments, and traversal segments (&#x60;.&#x60; and &#x60;..&#x60;) are invalid.
         * @param {number} retry Retry attempt number for the artifact.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        getStageArtifact(id: string, stageId: string, filename: string, retry: number, options?: RawAxiosRequestConfig): AxiosPromise<File> {
            return localVarFp.getStageArtifact(id, stageId, filename, retry, options).then((request) => request(axios, basePath));
        },
        /**
         * Lists captured artifact files for a run.
         * @summary List Run Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRunArtifacts(id: string, options?: RawAxiosRequestConfig): AxiosPromise<RunArtifactListResponse> {
            return localVarFp.listRunArtifacts(id, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns a paginated JSON list of stored run events. Ascending order uses `since_seq` as an inclusive cursor. Descending order uses `before_seq` as an exclusive cursor and starts at the newest event when `before_seq` is omitted.
         * @summary List Run Events
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {number} [limit] Maximum number of events to return.
         * @param {number} [beforeSeq] Exclusive upper event sequence cursor for descending order. Omit on the first descending request to start from the newest event.
         * @param {ListRunEventsOrderEnum} [order] Event sequence order. &#x60;since_seq&#x60; is valid only with &#x60;asc&#x60;; &#x60;before_seq&#x60; is valid only with &#x60;desc&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRunEvents(id: string, sinceSeq?: number, limit?: number, beforeSeq?: number, order?: ListRunEventsOrderEnum, options?: RawAxiosRequestConfig): AxiosPromise<PaginatedEventList> {
            return localVarFp.listRunEvents(id, sinceSeq, limit, beforeSeq, order, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the ordered list of stages in a run\'s workflow graph with their current status and timing. Stages are bounded by the workflow graph size, typically fewer than 20.
         * @summary List Run Stages
         * @param {string} id Unique run identifier (ULID).
         * @param {number} [pageLimit] Maximum number of items to return per page.
         * @param {number} [pageOffset] Number of items to skip before returning results.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listRunStages(id: string, pageLimit?: number, pageOffset?: number, options?: RawAxiosRequestConfig): AxiosPromise<PaginatedRunStageList> {
            return localVarFp.listRunStages(id, pageLimit, pageOffset, options).then((request) => request(axios, basePath));
        },
        /**
         * Lists artifact filenames stored for a stage.
         * @summary List Stage Artifacts
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listStageArtifacts(id: string, stageId: string, options?: RawAxiosRequestConfig): AxiosPromise<ArtifactListResponse> {
            return localVarFp.listStageArtifacts(id, stageId, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns a paginated JSON list of stored run events scoped to a single stage visit.
         * @summary List Stage Events
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} [sinceSeq] First event sequence number to include.
         * @param {number} [limit] Maximum number of events to return.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        listStageEvents(id: string, stageId: string, sinceSeq?: number, limit?: number, options?: RawAxiosRequestConfig): AxiosPromise<PaginatedEventList> {
            return localVarFp.listStageEvents(id, stageId, sinceSeq, limit, options).then((request) => request(axios, basePath));
        },
        /**
         * Uploads one or more artifacts for a stage. Intended for trusted internal callers.  The server accepts both: - `application/octet-stream` for single-file uploads with the `filename` query parameter - strict manifest-first `multipart/form-data` uploads documented by `ArtifactBatchUploadManifest`  The generated Rust client currently exposes the octet-stream variant because the OpenAPI code generator in this repo does not support multiple request media types on one operation.
         * @summary Put Stage Artifact
         * @param {string} id Unique run identifier (ULID).
         * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
         * @param {number} retry Retry attempt number for the artifact.
         * @param {File} body
         * @param {string} [filename] Relative artifact path for &#x60;application/octet-stream&#x60; uploads. Ignored for multipart uploads.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        putStageArtifact(id: string, stageId: string, retry: number, body: File, filename?: string, options?: RawAxiosRequestConfig): AxiosPromise<void> {
            return localVarFp.putStageArtifact(id, stageId, retry, body, filename, options).then((request) => request(axios, basePath));
        },
        /**
         * Reads a previously stored blob by hash.
         * @summary Read Run Blob
         * @param {string} id Unique run identifier (ULID).
         * @param {string} blobHash Content-addressed blob hash.
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        readRunBlob(id: string, blobHash: string, options?: RawAxiosRequestConfig): AxiosPromise<File> {
            return localVarFp.readRunBlob(id, blobHash, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the latest checkpoint data for a run, or null if no checkpoint has been recorded yet.
         * @summary Retrieve Run Checkpoint
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        retrieveRunCheckpoint(id: string, options?: RawAxiosRequestConfig): AxiosPromise<RunCheckpoint> {
            return localVarFp.retrieveRunCheckpoint(id, options).then((request) => request(axios, basePath));
        },
        /**
         * Returns the persisted dense `WorkflowSettings` snapshot used to launch this run.
         * @summary Retrieve Run Settings
         * @param {string} id Unique run identifier (ULID).
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        retrieveRunSettings(id: string, options?: RawAxiosRequestConfig): AxiosPromise<WorkflowSettings> {
            return localVarFp.retrieveRunSettings(id, options).then((request) => request(axios, basePath));
        },
        /**
         * Writes an opaque binary blob and returns its content-addressed blob hash.
         * @summary Write Run Blob
         * @param {string} id Unique run identifier (ULID).
         * @param {File} body
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        writeRunBlob(id: string, body: File, options?: RawAxiosRequestConfig): AxiosPromise<WriteBlobResponse> {
            return localVarFp.writeRunBlob(id, body, options).then((request) => request(axios, basePath));
        },
    };
};

/**
 * RunInternalsApi - object-oriented interface
 */
export class RunInternalsApi extends BaseAPI {
    /**
     * Appends a validated event to the run event log. Intended for trusted internal callers.
     * @summary Append Run Event
     * @param {string} id Unique run identifier (ULID).
     * @param {RunEvent} runEvent
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public appendRunEvent(id: string, runEvent: RunEvent, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).appendRunEvent(id, runEvent, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Opens an ordered server-sent event stream starting at `since_seq`, replaying persisted events and continuing with live updates while the run remains active.
     * @summary Attach Run Events
     * @param {string} id Unique run identifier (ULID).
     * @param {number} [sinceSeq] First event sequence number to include.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public attachRunEvents(id: string, sinceSeq?: number, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).attachRunEvents(id, sinceSeq, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Streams a ZIP archive with the latest captured version of each artifact path. Stage order, retry number, and then stage ID determine the latest version, matching the artifacts page. Captures from the graph\'s boundary nodes are excluded, identified by their `start` and `exit` handler type rather than by node name.  The archive streams, so the response status is sent before the first artifact is read. A failure after that point aborts the transfer rather than returning `500`. The ZIP central directory is written last, so a truncated download does not open as a valid archive.
     * @summary Download Run Artifacts
     * @param {string} id Unique run identifier (ULID).
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public downloadRunArtifacts(id: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).downloadRunArtifacts(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns one stored run event by source event sequence with content fields separated and truncated.
     * @summary Get Run Event Detail
     * @param {string} id Unique run identifier (ULID).
     * @param {number} seq
     * @param {number} [maxContentLength]
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getRunEventDetail(id: string, seq: number, maxContentLength?: number, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).getRunEventDetail(id, seq, maxContentLength, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the worker tracing log for a run when it is available.
     * @summary Get Run Logs
     * @param {string} id Unique run identifier (ULID).
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getRunLogs(id: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).getRunLogs(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns a byte-offset slice of a command stage output log. Bytes are base64-encoded and are not snapped to UTF-8 boundaries.
     * @summary Tail Command Log
     * @param {string} id Unique run identifier (ULID).
     * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
     * @param {number} [offset] Byte offset to start reading from. Defaults to &#x60;0&#x60;.
     * @param {number} [limit] Maximum bytes to return. Defaults to 65536 and is capped at 1048576.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getRunStageCommandLog(id: string, stageId: string, offset?: number, limit?: number, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).getRunStageCommandLog(id, stageId, offset, limit, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the latest best-effort model-visible context-window usage snapshot for an agent stage. Known stages without applicable or observed data return `available: false`; missing runs or stages return 404.
     * @summary Get Stage Context Window
     * @param {string} id Unique run identifier (ULID).
     * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getRunStageContextWindow(id: string, stageId: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).getRunStageContextWindow(id, stageId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the internal event-sourced run projection. This is not a stable public contract.
     * @summary Get Run State
     * @param {string} id Unique run identifier (ULID).
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getRunState(id: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).getRunState(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Downloads an artifact by filename.
     * @summary Get Stage Artifact
     * @param {string} id Unique run identifier (ULID).
     * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
     * @param {string} filename Relative artifact path. &#x60;/&#x60; is allowed as a path separator. Backslash, empty segments, and traversal segments (&#x60;.&#x60; and &#x60;..&#x60;) are invalid.
     * @param {number} retry Retry attempt number for the artifact.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public getStageArtifact(id: string, stageId: string, filename: string, retry: number, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).getStageArtifact(id, stageId, filename, retry, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Lists captured artifact files for a run.
     * @summary List Run Artifacts
     * @param {string} id Unique run identifier (ULID).
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listRunArtifacts(id: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).listRunArtifacts(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns a paginated JSON list of stored run events. Ascending order uses `since_seq` as an inclusive cursor. Descending order uses `before_seq` as an exclusive cursor and starts at the newest event when `before_seq` is omitted.
     * @summary List Run Events
     * @param {string} id Unique run identifier (ULID).
     * @param {number} [sinceSeq] First event sequence number to include.
     * @param {number} [limit] Maximum number of events to return.
     * @param {number} [beforeSeq] Exclusive upper event sequence cursor for descending order. Omit on the first descending request to start from the newest event.
     * @param {ListRunEventsOrderEnum} [order] Event sequence order. &#x60;since_seq&#x60; is valid only with &#x60;asc&#x60;; &#x60;before_seq&#x60; is valid only with &#x60;desc&#x60;.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listRunEvents(id: string, sinceSeq?: number, limit?: number, beforeSeq?: number, order?: ListRunEventsOrderEnum, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).listRunEvents(id, sinceSeq, limit, beforeSeq, order, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the ordered list of stages in a run\'s workflow graph with their current status and timing. Stages are bounded by the workflow graph size, typically fewer than 20.
     * @summary List Run Stages
     * @param {string} id Unique run identifier (ULID).
     * @param {number} [pageLimit] Maximum number of items to return per page.
     * @param {number} [pageOffset] Number of items to skip before returning results.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listRunStages(id: string, pageLimit?: number, pageOffset?: number, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).listRunStages(id, pageLimit, pageOffset, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Lists artifact filenames stored for a stage.
     * @summary List Stage Artifacts
     * @param {string} id Unique run identifier (ULID).
     * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listStageArtifacts(id: string, stageId: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).listStageArtifacts(id, stageId, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns a paginated JSON list of stored run events scoped to a single stage visit.
     * @summary List Stage Events
     * @param {string} id Unique run identifier (ULID).
     * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
     * @param {number} [sinceSeq] First event sequence number to include.
     * @param {number} [limit] Maximum number of events to return.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public listStageEvents(id: string, stageId: string, sinceSeq?: number, limit?: number, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).listStageEvents(id, stageId, sinceSeq, limit, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Uploads one or more artifacts for a stage. Intended for trusted internal callers.  The server accepts both: - `application/octet-stream` for single-file uploads with the `filename` query parameter - strict manifest-first `multipart/form-data` uploads documented by `ArtifactBatchUploadManifest`  The generated Rust client currently exposes the octet-stream variant because the OpenAPI code generator in this repo does not support multiple request media types on one operation.
     * @summary Put Stage Artifact
     * @param {string} id Unique run identifier (ULID).
     * @param {string} stageId Identifier of a stage within a run\&#39;s workflow graph, serialized as &#x60;node_id@visit&#x60;.
     * @param {number} retry Retry attempt number for the artifact.
     * @param {File} body
     * @param {string} [filename] Relative artifact path for &#x60;application/octet-stream&#x60; uploads. Ignored for multipart uploads.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public putStageArtifact(id: string, stageId: string, retry: number, body: File, filename?: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).putStageArtifact(id, stageId, retry, body, filename, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Reads a previously stored blob by hash.
     * @summary Read Run Blob
     * @param {string} id Unique run identifier (ULID).
     * @param {string} blobHash Content-addressed blob hash.
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public readRunBlob(id: string, blobHash: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).readRunBlob(id, blobHash, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the latest checkpoint data for a run, or null if no checkpoint has been recorded yet.
     * @summary Retrieve Run Checkpoint
     * @param {string} id Unique run identifier (ULID).
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public retrieveRunCheckpoint(id: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).retrieveRunCheckpoint(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Returns the persisted dense `WorkflowSettings` snapshot used to launch this run.
     * @summary Retrieve Run Settings
     * @param {string} id Unique run identifier (ULID).
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public retrieveRunSettings(id: string, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).retrieveRunSettings(id, options).then((request) => request(this.axios, this.basePath));
    }

    /**
     * Writes an opaque binary blob and returns its content-addressed blob hash.
     * @summary Write Run Blob
     * @param {string} id Unique run identifier (ULID).
     * @param {File} body
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    public writeRunBlob(id: string, body: File, options?: RawAxiosRequestConfig) {
        return RunInternalsApiFp(this.configuration).writeRunBlob(id, body, options).then((request) => request(this.axios, this.basePath));
    }
}

export const ListRunEventsOrderEnum = {
    ASC: 'asc',
    DESC: 'desc'
} as const;
export type ListRunEventsOrderEnum = typeof ListRunEventsOrderEnum[keyof typeof ListRunEventsOrderEnum];
