Skip to main content

Module attachments

Module attachments 

Source
Expand description

Prompt attachments: upload a file to the Grok Bot attachment store and get an alias to send with SendPrompt::attachment_paths.

The flow is BeginGrokBotAttachmentUpload → HTTPS PUT of the bytes to the presigned URL(s) the backend returned → CompleteGrokBotAttachmentUpload, which returns the alias. All four backend calls need a Cursor access token (a client built with Client::connect_cursor or Client::with_cursor_token).

The presigned PUT never carries a bearer token: only the headers the backend returned are sent, only to the exact URL it returned, and only over https (loopback http is allowed with Policy::allow_local_backend). Errors name the upload host, never the URL’s query string or signature.

Structs§

AttachmentRead
One resolved read (GrokBotAttachmentRead).
BeginUpload
BeginGrokBotAttachmentUpload response.
CompletedUpload
CompleteGrokBotAttachmentUpload response.
PresignedParts
PresignGrokBotAttachmentUploadParts response.
UploadPart
One presigned part (GrokBotAttachmentUploadPart).
UploadProgress
Progress of Client::upload_attachment.
UploadTarget
A presigned request target (GrokBotAttachmentUploadRequestTarget).
UploadedAttachment
A successfully uploaded attachment, ready for SendPrompt.

Enums§

AttachmentKind
The broad kind of a file, from its extension (drives the client-side size limit).
ReadOutcome
Where an attachment can be read from (GrokBotAttachmentReadOutcome).
UploadFailure
Why Client::upload_attachment could not produce an alias.
UploadMode
How the backend wants the file uploaded (GrokBotAttachmentUploadMode).
UploadRefusal
Why an upload was refused (GrokBotAttachmentUploadRefusal).

Constants§

MAX_ATTACHMENTS_PER_PROMPT
Most attachments the desktop app stages on one prompt.
MAX_FILE_BYTES
Size limit for non-image, non-video files.
MAX_IMAGE_BYTES
Image size limit the desktop app enforces before uploading (the server is final).
MAX_VIDEO_BYTES
Size limit for video.

Functions§

sha256_hex
SHA-256 as lowercase hex.
url_host
The host of a URL, without credentials, path or query.
validate_attachment
Check a file name and size the way the desktop app does before uploading.