export type UUIDSchema = string; export type ClosableStreamRepr = {value: string, encoding?: ('ascii' | 'base64') | undefined, close?: boolean | undefined}; export type CreateApiOperationsOperationIdSubprocessesSpidStdinArgs = {operationId: UUIDSchema, spid: number, body: ClosableStreamRepr}; export type CreateApiOperationsOperationIdSubprocessesSpidStdinOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Write to a subprocess's stdin and/or close it * * POST /operations/{operationId}/subprocesses/{spid}/stdin */ export const createApiOperationsOperationIdSubprocessesSpidStdin = async (args: CreateApiOperationsOperationIdSubprocessesSpidStdinArgs, options?: CreateApiOperationsOperationIdSubprocessesSpidStdinOptions) => { const {baseUrl = "https://api.tokenfactory.nebius.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/operations/${encodeURIComponent(String(args.operationId))}/subprocesses/${encodeURIComponent(String(args.spid))}/stdin${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };