Preview a computer file
Code Mode: praxis.agent.computers.files.retrievePreview
HTTP: GET /agent/v1/computers/{computer_id}/files/preview
The preview product of one version of one computer file: an image becomes a 1600 px WebP, an Office document a linearized PDF, text and source the first 64 KiB, and PDF, xlsx, epub, GIF, SVG and unknown types their original bytes. Products live in the File service and are keyed by computer, path, size, mtime, variant and format version. A request that pins v answers from that registry without stat’ing or waking the computer; without v the file is read and the product generated once. A file over the size threshold, or a deployment without the File service, answers fallback: "content" so the caller keeps the ordinary content door.
Signature
praxis.agent.computers.files.retrievePreview(args:{path:{/** pattern: ^cmp_[A-Za-z0-9_-]{1,64}$ */ computer_id:string};query:{path:string;v?:string;variant?:"auto"|"image"|"pdf"|"text"|"original"}}):Promise<{/** The product answered: image is a 1600 px WebP, pdf a linearized PDF, text the first 64 KiB of text or source, original the file's own bytes. */ variant:"image"|"pdf"|"text"|"original";/** The product version (<size>-<mtimeMs>-<variant>-fmt<N>) this answer belongs to; absent when the file has no mtime, so nothing may be pinned. */ version?:string;/** Media type of the product, or of the original bytes. */ mime_type?:string;/** Size of the product in bytes. */ size?:number;/** File id of the stored product in the File service, when the product was stored. */ file_id?:string;/** Signed read address of the product; the caller streams it and caches by the version it pinned. */ url?:string;/** When the signed read address stops working. */ expires_at?:string;/** true when an existing product answered without regenerating it. */ cached:boolean;/** Present as content when no product was produced: the file is over the size threshold or the deployment has no File service. */ fallback?:"content";/** true only on a pre-generation request over the kind's threshold, where generation was skipped. */ skipped?:boolean}>;Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| computer_id | path | string | yes | Computer id from computer creation or listing; a computer another tenant owns is not found. |
| path | query | string | yes | Absolute path of the file on the computer, or a /workspace/ relative path. |
| v | query | string | no | The file version to answer for: the file listing’s version (<size>-<mtimeMs>), or the full product version (<size>-<mtimeMs>-<variant>-fmt<N>) a previous answer returned. A pinned version answers from the product registry without a stat or a wake. |
| variant | query | “auto” | “image” | “pdf” | “text” | “original” | no | The product to answer; auto picks the kind’s own (image, pdf, text or original). A variant the file cannot produce answers 400 PREVIEW_VARIANT_UNAVAILABLE. |
Responses
| Status | Content types | Description |
|---|---|---|
| 200 | application/json | The preview product, or the fallback that sends the caller to the content door. |
| 400 | application/json | INVALID_PARAMS: path is missing, a query parameter is unsupported, the pinned version is malformed, or PREVIEW_VARIANT_UNAVAILABLE: this file has no such variant. |
| 401 | application/json | Platform error in the one /agent/v1 error body; computer failures add error.hint |
| 403 | application/json | Platform error in the one /agent/v1 error body; computer failures add error.hint |
| 404 | application/json | Computer or path not found; foreign computers are indistinguishable from absent computers. |
| 409 | application/json | STALE_DIGEST: the file changed while its product was read; ask again. |
| 413 | application/json | FILE_TOO_LARGE: the file exceeds the preview transfer limit; read it through the sandbox connection issued by connect, or use the content door. |
| 429 | application/json | Platform error in the one /agent/v1 error body; computer failures add error.hint |
| 500 | application/json | Platform error in the one /agent/v1 error body; computer failures add error.hint |
| 503 | application/json | PREVIEW_UNAVAILABLE: preview products or image transformation are not configured for this deployment, or the File service could not be reached; retry later. |