Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPreconditionFailed = errors.New("s3: precondition failed")
ErrPreconditionFailed is returned by UploadTarGz when an If-Match or If-None-Match precondition fails (HTTP 412). Optimistic-lock callers distinguish this from a transport error and decide whether to drop their write or retry after re-fetching.
var TempDirBase = ""
TempDirBase is the parent under which per-session work directories are created. Tests override it via t.TempDir(); production uses os.TempDir().
Functions ¶
func Teardown ¶
Teardown uploads the per-session jsonl, then packages ClaudeDir as a tar.gz (excluding this session's subtree) and uploads it. Finally, the temp dir is removed. Upload failures are logged but do not propagate — a flaky upload must not block the caller's turn response. TempDir is always removed.
Types ¶
type S3Config ¶
type S3Config struct {
Endpoint string
Region string
Bucket string
AccessKeyID string
SecretAccessKey string
PathStyle bool
}
S3Config carries the S3-compatible endpoint configuration.
Endpoint is a full URL with scheme — http://... or https://... — so operators can use the same form they paste into rclone / aws cli. Trailing path segments are not supported. PathStyle must be true for MinIO and most on-prem S3 implementations; false for AWS S3 (virtual-hosted-style is required) and most public clouds.
type S3Store ¶
type S3Store struct {
// contains filtered or unexported fields
}
S3Store is the workspace persistence backend. One instance is held by the server and shared across all turns.
func NewS3Store ¶
func (*S3Store) DownloadTarGz ¶
DownloadTarGz streams the object at key, gunzip-untars it into destDir. Returns the object's ETag so callers can pass it back as the IfMatch precondition on a subsequent UploadTarGz (optimistic concurrency). On 404 the returned etag is empty and err is nil — caller treats it as a fresh workspace and may upload with IfNoneMatch:"*" to assert "create only". Tar entries with paths escaping destDir are skipped.
func (*S3Store) UploadTarGz ¶
func (s *S3Store) UploadTarGz(ctx context.Context, srcDir, key string, excludeRel func(rel string) bool, opts UploadOpts) error
UploadTarGz walks srcDir, packages it as a tar.gz, and PUTs it to the given key. The tarball is buffered in memory so the SDK can issue a single PUT request (avoids multipart for the typical small workspace payload). Symlinks are skipped. File modes are normalized to 0644 (regular) / 0755 (dir). Failures during walk are logged and the offending file is skipped; the upload still completes with whatever was packed.
excludeRel, if non-nil, returns true for any rel-path under srcDir that should be omitted from the tarball. Used by callers that store some subdirectories as separate S3 objects (per-session jsonl).
Returns ErrPreconditionFailed when opts.IfMatch / IfNoneMatch are violated — the caller can choose to drop the write or retry after re-syncing.
type UploadOpts ¶ added in v0.44.0
type UploadOpts struct {
IfMatch string // only PUT if current ETag matches; "" = unconstrained
IfNoneMatch string // only PUT if no object exists when set to "*"; "" = unconstrained
}
UploadOpts carries optional preconditions for an optimistic-locked PUT. At most one of IfMatch / IfNoneMatch should be set. Both empty means unconditional write (overwrite or create regardless of current state).
type Workspace ¶
type Workspace struct {
WorkspaceID string
SessionID string
TempDir string // root: /tmp/cc-broker/sess_<sessionID>
ClaudeDir string // <TempDir>/claude-config — CLAUDE_CONFIG_DIR
ProjectDir string // <TempDir>/project — CLI cwd (kept empty; only used for proj_hash)
MemoryDir string // <ClaudeDir>/projects/ws_<wid>/memory — auto-memory override
// contains filtered or unexported fields
}
Workspace is the ephemeral local filesystem view a single CC turn operates in.
func Setup ¶
Setup creates the temp directory tree, downloads the workspace's claude-home tarball, and downloads the per-session jsonl. The returned Workspace must be passed to Teardown so the temp directory is removed and state is uploaded back.
On any error after the directory tree is created, Setup removes TempDir before returning, so callers do not leak per-session directories.