Skip to content
中文

Write computer file content

Code Mode: praxis.agent.computers.files.updateContent

HTTP: PUT /agent/v1/computers/{computer_id}/files/content

Write the bytes of one existing file on a computer, only if the file is still the version you read.

Send the raw bytes as the body (at most 16 MiB) and the version you edited in If-Match: the version field of the file listing (<size>-<mtimeMs>). The file must already exist; the write replaces it whole and keeps its permissions. A request without If-Match answers 428 FILE_VERSION_REQUIRED and nothing is written. When the file has changed since that version, the answer is 412 FILE_VERSION_MISMATCH with error.current_version, and nothing is written: read the file again, redo the edit and write with the new version. The version is checked against the file’s current size and modification time, then the content digest is bound into the write itself, so a change that lands while the bytes are being written is refused instead of overwritten. Paths under /attachments and /skills are read-only (403 READ_ONLY). A successful write answers the new path, size, mtime and version; use that version for the next write.

Signature

praxis.agent.computers.files.updateContent(args:{path:{/** pattern: ^cmp_[A-Za-z0-9_-]{1,64}$ */ computer_id:string};query:{path:string};headers?:{"If-Match":string};body:Blob|File}):Promise<{/** Absolute path of the file that was written. */ path:string;/** Size of the file now, in bytes. */ size:number;/** Modification time of the file now, when the machine reports one. */ mtime:string|null;/** The file's version now (<size>-<mtimeMs>); send it as If-Match on the next write. */ version:string}>;

Parameters

NameInTypeRequiredDescription
computer_idpathstringyesComputer id from computer creation or listing; a computer another tenant owns is not found.
pathquerystringyesAbsolute path of the existing file on the computer, or a /workspace/ relative path.
If-MatchheaderstringyesThe file version you edited, as the file listing gives it (<size>-<mtimeMs>); a quoted value is accepted.

Request body

RequiredContent typesDescription
yesapplication/octet-stream

Responses

StatusContent typesDescription
200application/jsonThe file after the write.
400application/jsonINVALID_PARAMS: path is missing, a query parameter is unsupported, or the path is a directory (IS_DIRECTORY).
401application/jsonPlatform error in the one /agent/v1 error body; computer failures add error.hint
403application/jsonREAD_ONLY: the path is under /attachments or /skills.
404application/jsonComputer or path not found; foreign computers are indistinguishable from absent computers, and a write never creates a file.
412application/jsonFILE_VERSION_MISMATCH: the file changed since the version in If-Match; error.current_version is its version now. Nothing was written.
413application/jsonFILE_TOO_LARGE: the body exceeds 16 MiB.
428application/jsonFILE_VERSION_REQUIRED: If-Match is missing. Nothing was written.
429application/jsonPlatform error in the one /agent/v1 error body; computer failures add error.hint
500application/jsonPlatform error in the one /agent/v1 error body; computer failures add error.hint
503application/jsonPlatform error in the one /agent/v1 error body; computer failures add error.hint