- Update CI (unit-test.yml, pr-test.yml) to use yaoapp/tai:1.2.0 with new default ports (gRPC:19100, HTTP:8099, VNC:16080, Docker:12375) - Add explicit 0.0.0.0 bind for containerized Tai instances - Fix sandbox/v2 grpc.go default port fallback (9100 → 19100) - Fix tai/tunnel/proxy.go fallback ports (8080→8099, 6080→16080) - Sync tai SDK and sandbox/v2 documentation with implementation - Add new docs: api.md, registry.md, tunnel.md Made-with: Cursor
67 lines
1.9 KiB
Go
67 lines
1.9 KiB
Go
package volume
|
|
|
|
import (
|
|
"context"
|
|
"io/fs"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
// Volume provides filesystem IO and directory synchronization.
|
|
// Remote connects to Tai gRPC :19100; Local operates directly on disk.
|
|
type Volume interface {
|
|
ReadFile(ctx context.Context, sessionID, path string) ([]byte, os.FileMode, error)
|
|
WriteFile(ctx context.Context, sessionID, path string, data []byte, perm os.FileMode) error
|
|
Stat(ctx context.Context, sessionID, path string) (*FileInfo, error)
|
|
ListDir(ctx context.Context, sessionID, path string) ([]FileInfo, error)
|
|
Remove(ctx context.Context, sessionID, path string, recursive bool) error
|
|
Rename(ctx context.Context, sessionID, oldPath, newPath string) error
|
|
MkdirAll(ctx context.Context, sessionID, path string) error
|
|
|
|
SyncPush(ctx context.Context, sessionID, localDir string, opts ...SyncOption) (*SyncResult, error)
|
|
SyncPull(ctx context.Context, sessionID, localDir string, opts ...SyncOption) (*SyncResult, error)
|
|
|
|
Close() error
|
|
}
|
|
|
|
// FileInfo describes a single file or directory.
|
|
type FileInfo struct {
|
|
Path string
|
|
Size int64
|
|
Mtime time.Time
|
|
Mode fs.FileMode
|
|
IsDir bool
|
|
}
|
|
|
|
// SyncResult summarizes a SyncPush or SyncPull operation.
|
|
type SyncResult struct {
|
|
FilesSynced int
|
|
BytesTransferred int64
|
|
Duration time.Duration
|
|
}
|
|
|
|
// SyncOption configures sync behavior.
|
|
type SyncOption func(*syncConfig)
|
|
|
|
type syncConfig struct {
|
|
forceFull bool
|
|
excludes []string
|
|
}
|
|
|
|
// WithForceFull skips snapshot caches and diffs against actual disk.
|
|
func WithForceFull() SyncOption {
|
|
return func(c *syncConfig) { c.forceFull = true }
|
|
}
|
|
|
|
// WithExcludes adds glob patterns to exclude from sync.
|
|
func WithExcludes(patterns ...string) SyncOption {
|
|
return func(c *syncConfig) { c.excludes = append(c.excludes, patterns...) }
|
|
}
|
|
|
|
func applySyncOpts(opts []SyncOption) syncConfig {
|
|
var cfg syncConfig
|
|
for _, o := range opts {
|
|
o(&cfg)
|
|
}
|
|
return cfg
|
|
}
|