files

package
v0.2.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 53 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Text edits derive from the reviewed confined file service (Apache-2.0).

Codex patch parsing and exact matching derive from openai/codex 451787127c0e70247034c33e358536ffd2b89cf8 (Apache-2.0).

Default file types adapted from ripgrep ignore 0.4.33 (MIT or Unlicense).

Package files owns workspace effects outside the Node database writer.

Index

Constants

View Source
const MaxCaptureBytes = 20 * 1024 * 1024

MaxCaptureBytes is the largest screenshot a tool may hand to PrepareCapture.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, root string, p *Prepared) (protocol.Output, error)

func ApplyHunkText

func ApplyHunkText(current, from, to string) (string, error)

func ApplyPatchChunks

func ApplyPatchChunks(before string, chunks []PatchChunk) (string, error)

func Browse

func ChangedExcerpt

func ChangedExcerpt(before, after string) *protocol.FileExcerpt

ChangedExcerpt reports bounded numbered regions from the exact prepared text.

func Inspect

func Inspect(ctx context.Context, root string, command protocol.Command, access core.FileAccess, document Document) (protocol.Output, error)

func IsVolume

func IsVolume(goos string, mount disk.PartitionStat) bool

IsVolume reports whether a mount of goos is a volume the user stores files on, the one rule of the file browser's devices and of the host metrics' disks: not a pseudo file system, not one of the system's own mounts (removable media under /run/media stay), and on macOS not one the system hides from its file browser (nobrowse: /dev, /System/Volumes/*, Recovery).

func MutateEntries

func MutateEntries(ctx context.Context, source, root string, command protocol.Command, access core.FileAccess) (protocol.Output, error)

MutateEntries receives independently captured source and destination roots.

func PrepareArtifactHTML

func PrepareArtifactHTML(kind protocol.ArtifactKind, source string, allowedClasses []string) (string, []string, error)

func PrepareCapture

func PrepareCapture(data []byte) (protocol.ImageFacts, *protocol.ImageFacts, []byte, error)

PrepareCapture bounds a screenshot a tool produced. A capture is taken at the size of its subject, so it is accepted up to MaxCaptureBytes and reduced like any other image instead of being refused.

func PrepareCreation

func PrepareCreation(path, text string) (string, error)

PrepareCreation assigns stable IDs to generated v4.5 notebook cells before approval.

func PrepareEdits

func PrepareEdits(before string, edits []protocol.FileEdit) (string, error)

func PrepareImage

func PrepareImage(data []byte) (protocol.ImageFacts, *protocol.ImageFacts, []byte, error)

PrepareImage bounds an image a user or a file supplies. It returns the source facts, the facts of the reduced image when one was made, and the bytes to send.

func PrepareNotebook

func PrepareNotebook(before string, input protocol.NotebookEdit) (string, error)

func ReadArtifactHTML

func ReadArtifactHTML(ctx context.Context, profile string, artifact protocol.ArtifactSummary, digest string) (string, error)

ReadArtifactHTML verifies immutable content after its metadata read lease ends.

func ReadImage

func ReadImage(ctx context.Context, f *core.Files, path string) (protocol.FileImage, error)

func RemoveArtifacts

func RemoveArtifacts(profile string, sessions []protocol.SessionID) error

RemoveArtifacts deletes the artifact directories of the given sessions. The caller names only sessions that keep no artifact row.

func ResolvePatchWithRevisions

func ResolvePatchWithRevisions(ctx context.Context, root, input string, observed map[string]string, access core.FileAccess) ([]protocol.FileChange, error)

func RestoreCheckpoint

RestoreCheckpoint puts back the content a file had before the checkpoint's change. settled lists the versions the file had before this change or an earlier change of the same turn (nil is an absent file): a file that already holds one of them is restored and is left as it is, so repeating an Undo succeeds. Any other content is another change and is not overwritten.

func Search(ctx context.Context, files *core.Files, input protocol.FileSearch) (protocol.SearchResults, error)

func SupportsMutation

func SupportsMutation(kind string) bool

func SupportsRead

func SupportsRead(kind string) bool

func TextDiff

func TextDiff(path, before, after string) (string, uint64, uint64)

func ValidateAttachment

func ValidateAttachment(spec protocol.AttachmentSpec) error

func WriteArtifactHTML

func WriteArtifactHTML(ctx context.Context, profile string, artifact protocol.ArtifactSummary, html string) (string, error)

WriteArtifactHTML publishes a captured unreferenced revision. SQL metadata is committed by the caller only after this physical receipt is returned.

Types

type BrowserTarget

type BrowserTarget struct{ Root, Name string }

func BrowserTargets

func BrowserTargets(action protocol.FileBrowserAction) ([]BrowserTarget, error)

type Document

type Document func(ctx context.Context, name string, data []byte, offset uint64) (protocol.OfficeInspection, error)

Document inspects the bytes of a document or image file. The Node supplies it so that images and scanned pages are read with its OCR model.

type HunkChange

type HunkChange struct {
	Hunk          protocol.ConversationCheckpointHunk
	Before, After string
}

func SplitHunks

func SplitHunks(path, before, after string, segment int) ([]HunkChange, error)

type PatchChunk

type PatchChunk struct {
	Context   *string
	Old, New  []string
	Kept      [][2]int
	EndOfFile bool
}

type PatchHunk

type PatchHunk struct {
	Kind, Path, Contents string
	Destination          *string
	Chunks               []PatchChunk
}

func ParsePatch

func ParsePatch(input string) ([]PatchHunk, error)

type Prepared

type Prepared struct {
	Command  protocol.Command
	Access   core.FileAccess
	Changes  []PreparedChange
	Preview  protocol.ChangePreview
	Rejected *protocol.FileChanges
}

func Prepare

func Prepare(ctx context.Context, root string, command protocol.Command, access core.FileAccess) (*Prepared, error)

type PreparedChange

type PreparedChange struct {
	Operation        string
	Kind             protocol.ChangeKind
	Path             string
	Destination      *string
	Before           *string
	After            *string
	ExpectedRevision *string
}

type StreamScope

type StreamScope struct {
	Worktree protocol.WorktreeID
	Draft    bool
}

type Transfers

type Transfers struct {
	// contains filtered or unexported fields
}

Transfers is the one resource owner for authenticated, single-use file streams. Prepared uploads retain confined publication targets until the durable finish.

func NewTransfers

func NewTransfers(profile string) *Transfers

NewTransfers also removes the staging files an earlier process left: a process that is killed cannot run its cleanup, and one process owns a profile, so every staging file found at start is an orphan.

func (*Transfers) AttachmentBytes

func (t *Transfers) AttachmentBytes(ctx context.Context, attachment protocol.Attachment) ([]byte, error)

func (*Transfers) BeginThumbnail added in v0.2.6

func (t *Transfers) BeginThumbnail(ctx context.Context, edge uint32) (context.Context, func(), error)

BeginThumbnail bounds preparation before even opening a source or reading its canonical bytes. The caller holds the slot through its scope recheck.

func (*Transfers) Cancel

func (t *Transfers) Cancel(caller protocol.NodeID, user protocol.UserID, id protocol.StreamID) error

func (*Transfers) ClaimBackup

func (transfers *Transfers) ClaimBackup(caller protocol.NodeID, id protocol.StreamID) (file *os.File, size uint64, release func(), err error)

ClaimBackup takes a completed archive upload out of the transfer table. The caller reads the file and then calls release, which removes the staging.

func (*Transfers) Close

func (t *Transfers) Close() error

func (*Transfers) CollectAttachments

func (t *Transfers) CollectAttachments(retained map[protocol.AttachmentID]bool) error

CollectAttachments removes every stored attachment file whose identifier is not retained. A finished upload publishes its file before its row commits, so the caller must exclude that window: it runs while no upload can finish or under a lock that every finishing upload holds from its file to its row.

func (*Transfers) DownloadAttachment

func (t *Transfers) DownloadAttachment(ctx context.Context, caller protocol.NodeID, user protocol.UserID, root string, attachment protocol.Attachment) (protocol.AttachmentDownload, error)

func (*Transfers) DownloadAttachmentThumbnail added in v0.2.6

func (t *Transfers) DownloadAttachmentThumbnail(ctx context.Context, caller protocol.NodeID, user protocol.UserID, root string, attachment protocol.Attachment, edge uint32) (protocol.AttachmentDownload, error)

func (*Transfers) DownloadBackup

func (transfers *Transfers) DownloadBackup(ctx context.Context, caller protocol.NodeID, archive string, record protocol.BackupRecord, revision string) (protocol.BackupDownload, error)

DownloadBackup takes ownership of a sealed archive inside the profile's temporary directory and serves it once. Only the controller-facing backup service registers private archive files.

func (*Transfers) DownloadBytes

func (t *Transfers) DownloadBytes(ctx context.Context, caller protocol.NodeID, root string, attachment protocol.Attachment, data []byte, thumbnailEdge uint32) (protocol.AttachmentDownload, error)

DownloadBytes serves a captured canonical image without exposing blob storage.

func (*Transfers) DownloadFile

func (t *Transfers) DownloadFile(ctx context.Context, caller protocol.NodeID, root string, worktree protocol.WorktreeID, path string, access core.FileAccess) (protocol.FileDownload, error)

func (*Transfers) DownloadFileThumbnail added in v0.2.6

func (t *Transfers) DownloadFileThumbnail(ctx context.Context, caller protocol.NodeID, root string, worktree protocol.WorktreeID, path string, access core.FileAccess, edge uint32) (protocol.FileDownload, error)

func (*Transfers) DownloadSSH

func (transfers *Transfers) DownloadSSH(ctx context.Context, caller protocol.NodeID, client *sftp.Client, path string) (protocol.SshDownload, error)

DownloadSSH stages a remote file on this Node and serves it through a caller-owned, single-use download stream.

func (*Transfers) Finish

func (t *Transfers) Finish(ctx context.Context, caller protocol.NodeID, user protocol.UserID, root string, command protocol.Command) (protocol.Output, error)

func (*Transfers) FinishSSHUpload

func (transfers *Transfers) FinishSSHUpload(caller protocol.NodeID, client *sftp.Client, profile protocol.SshProfile, path string, stream protocol.StreamID) (uint64, error)

FinishSSHUpload consumes a completely staged upload exactly once. A request naming another caller, profile revision or path leaves the stage untouched; once publication starts the stage is gone whatever the remote result.

func (*Transfers) Open

func (*Transfers) OpenAttachment

func (t *Transfers) OpenAttachment(attachment protocol.Attachment) (*os.File, error)

func (*Transfers) PluginFormat

func (transfers *Transfers) PluginFormat(caller protocol.NodeID, id protocol.StreamID) (protocol.PluginSkillsArchiveFormat, error)

func (*Transfers) Remove

func (t *Transfers) Remove(root string)

func (*Transfers) Scope

func (t *Transfers) Scope(caller protocol.NodeID, user protocol.UserID, id protocol.StreamID) (StreamScope, bool, error)

Scope reads the captured resource before Open consumes the single-use transfer. Ownership is checked here and again when the resource stream is opened.

func (*Transfers) SetPluginFormat

func (transfers *Transfers) SetPluginFormat(caller protocol.NodeID, id protocol.StreamID, format protocol.PluginSkillsArchiveFormat) error

func (*Transfers) StageInputs

func (t *Transfers) StageInputs(ctx context.Context, attachments []protocol.Attachment) (string, func(), error)

StageInputs creates verified command-local copies. Attachment IDs, never display names, identify the files in SAILRY_ATTACHMENTS.

func (*Transfers) StagePluginUpload

func (transfers *Transfers) StagePluginUpload(ctx context.Context, caller protocol.NodeID, data []byte) (protocol.PluginUpload, error)

func (*Transfers) StageSSHUpload

func (transfers *Transfers) StageSSHUpload(ctx context.Context, caller protocol.NodeID, spec protocol.SshUploadSpec) (protocol.SshUpload, error)

StageSSHUpload reserves a caller-owned stream that stages bytes on this Node. The remote host is not contacted until FinishSSHUpload publishes them.

func (*Transfers) TransferSSH

func (transfers *Transfers) TransferSSH(ctx context.Context, connection *cryptossh.Client, root string, access core.FileAccess, transfer protocol.SshTransfer) (uint64, error)

TransferSSH copies one file between a confined worktree path and an explicit remote path. Bytes never leave this Node's side of the connection. A download is staged in Node storage and published without following links; once publication starts it runs to completion regardless of ctx.

func (*Transfers) UploadAttachment

func (t *Transfers) UploadAttachment(ctx context.Context, caller protocol.NodeID, user protocol.UserID, root string, spec protocol.AttachmentSpec) (protocol.AttachmentUpload, error)

func (*Transfers) UploadBackup

func (transfers *Transfers) UploadBackup(ctx context.Context, caller protocol.NodeID, size uint64, revision string) (protocol.BackupUpload, error)

UploadBackup reserves private staging for one sealed archive.

func (*Transfers) UploadFile

func (t *Transfers) UploadFile(ctx context.Context, caller protocol.NodeID, root string, spec protocol.FileUploadSpec, access core.FileAccess) (protocol.FileUpload, error)

func (*Transfers) UploadPlugin

func (transfers *Transfers) UploadPlugin(ctx context.Context, caller protocol.NodeID, spec protocol.PluginUploadSpec) (protocol.PluginUpload, error)

func (*Transfers) UsePluginUpload

func (transfers *Transfers) UsePluginUpload(ctx context.Context, caller protocol.NodeID, id protocol.StreamID, consume bool, use func(io.ReaderAt, int64) error) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL