Documentation
¶
Overview ¶
Package workspace 提供 Agent 任务运行所需的共享文件系统约定。
Index ¶
- func ArtifactStoragePath(orgID uint, workerID uint, storageKey string) (string, error)
- func FindRepoRoot(workDir string) (string, error)
- func OpenArtifactStorageFile(ctx context.Context, orgID uint, workerID uint, storageKey string) (io.ReadCloser, error)
- func PrepareTempWorkspace() (string, error)
- func ProjectMemoryPath(repoDir string) string
- func ProjectRepoPath(orgID uint, workerID uint, publicID string) (string, error)
- func ReconcileArtifacts(ctx context.Context, plan *TaskWorkspace) error
- func RepoRelativePathFromStorageKey(storageKey string) string
- func SafeJoin(root string, child string) (string, error)
- func WorkerMountedWorkspacePath(orgID uint, workerID uint) (string, error)
- func WriteBaseline(ctx context.Context, plan *TaskWorkspace) error
- type ArtifactRecord
- type ArtifactStorageFile
- type FileSnapshot
- type IgnoreChecker
- type ManifestArtifact
- type TaskWorkspace
- type TaskWorkspaceRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArtifactStoragePath ¶
ArtifactStoragePath 从 server 侧解析 worker workspace 相对的 storage key。
func FindRepoRoot ¶
FindRepoRoot 从给定的工作目录向上查找包含 .leros 目录的 repo 根目录。
func OpenArtifactStorageFile ¶
func PrepareTempWorkspace ¶
PrepareTempWorkspace 创建没有项目上下文时使用的临时兜底工作区。
func ProjectMemoryPath ¶
ProjectMemoryPath 返回项目记忆文件的绝对路径。 repoDir 是项目 repo 根目录的绝对路径。
func ProjectRepoPath ¶
ProjectRepoPath 返回项目 repo 在 worker workspace 下的绝对路径。 路径格式:{workspaceRoot}/{orgID}/{workerID}/workspace/projects/{orgID}/{publicID}/repo
func ReconcileArtifacts ¶
func ReconcileArtifacts(ctx context.Context, plan *TaskWorkspace) error
ReconcileArtifacts compares the current repo state against the baseline, identifies new or modified files, and populates the manifest at plan.ArtifactManifestPath with any autodetected artifacts. It skips reconciliation when the manifest already contains final entries.
func WorkerMountedWorkspacePath ¶
WorkerMountedWorkspacePath 返回 server 视角下某个 worker 的 workspace 挂载目录。 Server 挂载的是 workspace 根目录,单个 Worker 的实际目录位于 {workspaceRoot}/{orgID}/{workerID}/workspace。
func WriteBaseline ¶
func WriteBaseline(ctx context.Context, plan *TaskWorkspace) error
WriteBaseline scans the repo directory, applies ignore rules, and writes a baseline.jsonl.
Types ¶
type ArtifactRecord ¶
type ArtifactRecord struct {
Title string
Filename string
Description string
ArtifactType string
RelativePath string
StorageKey string
MimeType string
FileSize int64
Sha256 string
Source string
Status string
}
ArtifactRecord 是 manifest 产物声明经过校验后可持久化的结构。
func BuildArtifactRecord ¶
func BuildArtifactRecord(plan *TaskWorkspace, item ManifestArtifact) (ArtifactRecord, error)
BuildArtifactRecord 校验一条产物声明,并生成可存储的产物记录。
func CollectFinalArtifacts ¶
func CollectFinalArtifacts(ctx context.Context, plan *TaskWorkspace) ([]ArtifactRecord, error)
CollectFinalArtifacts 读取并校验最终产物 manifest。
type ArtifactStorageFile ¶
type ArtifactStorageFile struct {
Path string
Filename string
MimeType string
FileSize int64
Sha256 string
Data []byte
}
type FileSnapshot ¶
type FileSnapshot struct {
Path string `json:"path"`
Size int64 `json:"size"`
MtimeUnixNano int64 `json:"mtime_unix_nano"`
}
FileSnapshot records a single file's metadata at a point in time.
type IgnoreChecker ¶
type IgnoreChecker struct {
// contains filtered or unexported fields
}
IgnoreChecker applies gitignore rules and Leros built-in excludes.
func NewIgnoreChecker ¶
func NewIgnoreChecker(repoDir string) (*IgnoreChecker, error)
NewIgnoreChecker creates an IgnoreChecker for the given repo directory.
func (*IgnoreChecker) IsIgnored ¶
func (c *IgnoreChecker) IsIgnored(absPath string) (bool, error)
IsIgnored returns true when a file should be excluded from scanning.
func (*IgnoreChecker) ShouldSkipDir ¶
func (c *IgnoreChecker) ShouldSkipDir(absPath string) bool
ShouldSkipDir returns true when a directory should be excluded from scanning entirely.
type ManifestArtifact ¶
type ManifestArtifact struct {
Path string `json:"path"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
MimeType string `json:"mime_type,omitempty"`
ArtifactType string `json:"artifact_type,omitempty"`
IsFinal bool `json:"is_final,omitempty"`
}
ManifestArtifact 表示 Agent 在一次 turn 中写入 JSON Lines manifest 的一条产物声明。
type TaskWorkspace ¶
type TaskWorkspace struct {
WorkspaceRoot string
ProjectRoot string
RepoDir string
TaskDir string
TurnDir string
TurnTmpDir string
TurnLogDir string
ArtifactManifestPath string
BaselinePath string
EffectiveWorkDir string
}
TaskWorkspace 描述一次任务 turn 会使用到的文件系统路径。
func FromAgentRequest ¶
func FromAgentRequest(req *agent.RequestContext) (*TaskWorkspace, bool, error)
FromAgentRequest 从标准化运行请求中的 workspace 上下文解析工作区路径。
func PrepareTaskWorkspace ¶
func PrepareTaskWorkspace(ctx context.Context, req TaskWorkspaceRequest) (*TaskWorkspace, error)
PrepareTaskWorkspace 创建并校验项目任务工作区。
func ResolveTaskWorkspace ¶
func ResolveTaskWorkspace(req TaskWorkspaceRequest) (*TaskWorkspace, error)
ResolveTaskWorkspace 只计算任务 turn 工作区路径,不创建任何目录。
func (*TaskWorkspace) StorageKey ¶
func (p *TaskWorkspace) StorageKey(relativePath string) (string, error)
StorageKey 返回适合持久化的 workspace root 相对路径。