Documentation
¶
Overview ¶
Package artifact owns session-scoped deliverables. Workspace artifacts keep their content in the registered workspace; managed artifacts keep validated content below JCode's private artifact root. Persisted metadata never contains an absolute path or file content.
Index ¶
- Constants
- Variables
- type Kind
- type Loader
- type ManagedImageRequest
- type Record
- type Recorder
- type Ref
- type RegisterRequest
- type Service
- func (s *Service) CreateManagedImage(ctx context.Context, req ManagedImageRequest, recorder Recorder) (Record, error)
- func (s *Service) List(ctx context.Context, sessionID, workspace string) ([]Record, error)
- func (s *Service) ListManaged(ctx context.Context, sessionID string) ([]Record, error)
- func (s *Service) Open(ctx context.Context, sessionID, workspace, artifactID string) (Record, *os.File, error)
- func (s *Service) Register(ctx context.Context, req RegisterRequest, recorder Recorder) (Record, error)
- func (s *Service) Resolve(ctx context.Context, sessionID, workspace, artifactID string) (Record, string, error)
- type Status
- type StorageKind
Constants ¶
const ( MaxInlineTextSize int64 = 5 << 20 MaxInlineBinarySize int64 = 25 << 20 MaxDownloadSize int64 = 250 << 20 )
Variables ¶
var ErrTooLarge = errors.New("artifact is too large")
Functions ¶
This section is empty.
Types ¶
type ManagedImageRequest ¶ added in v0.12.3
type ManagedImageRequest struct {
SessionID string
Title string
Reader io.Reader
ProviderID string
ModelID string
ParentArtifactID string
OperationID string
ToolCallID string
Focus bool
// Expected values are optional defense-in-depth assertions against metadata
// supplied by an adapter. The bytes remain the source of truth.
ExpectedMediaType string
ExpectedWidth int
ExpectedHeight int
ExpectedSHA256 string
}
ManagedImageRequest is the only P0 managed-content write contract. The caller supplies bytes, not a path; the service chooses the opaque ID, key, extension, permissions, and final location from validated content.
type Record ¶
type Record struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
StorageKind StorageKind `json:"storage_kind,omitempty"`
RelativePath string `json:"relative_path,omitempty"`
RelativeKey string `json:"relative_key,omitempty"`
Title string `json:"title"`
Kind Kind `json:"kind"`
MediaType string `json:"media_type"`
Size int64 `json:"size"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
SHA256 string `json:"sha256,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
ModelID string `json:"model_id,omitempty"`
ParentArtifactID string `json:"parent_artifact_id,omitempty"`
OperationID string `json:"operation_id,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Revision int `json:"revision"`
UpdatedAt time.Time `json:"updated_at"`
Status Status `json:"status"`
// Focus is never omitted: false is a deliberate instruction to keep the
// Artifact unseen without stealing the active panel, while older clients
// may treat an absent field as the legacy focus=true behavior.
Focus bool `json:"focus"`
}
Record is the metadata persisted in a session entry and exposed to the Web UI. It intentionally contains neither an absolute path nor file content.
func (Record) EffectiveShareable ¶ added in v0.12.3
EffectiveShareable preserves the v1 workspace contract. Workspace Artifacts predate the persisted shareable bit and remain shareable; managed media is fail-closed unless a future storage policy explicitly opts it in.
func (Record) EffectiveStorageKind ¶ added in v0.12.3
func (r Record) EffectiveStorageKind() StorageKind
EffectiveStorageKind preserves the v1 contract: a missing storage_kind is a workspace record, never a managed key guessed from other fields.
type Recorder ¶
Recorder is the durable boundary. Register never publishes a revision until this append succeeds.
type Ref ¶ added in v0.12.3
type Ref struct {
ID string `json:"id"`
StorageKind StorageKind `json:"storage_kind"`
RelativeKey string `json:"relative_key,omitempty"`
Title string `json:"title"`
Kind Kind `json:"kind"`
MediaType string `json:"media_type"`
Size int64 `json:"size"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
SHA256 string `json:"sha256,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
ModelID string `json:"model_id,omitempty"`
ParentArtifactID string `json:"parent_artifact_id,omitempty"`
OperationID string `json:"operation_id,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
Ref is the transport-safe, path-free projection returned by tools and live events. Content remains accessible only through Service.Open/Resolve.
type RegisterRequest ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewServiceWithManagedRoot ¶ added in v0.12.3
NewServiceWithManagedRoot is intended for isolated runtimes and tests. The supplied path is the trusted root itself; callers must not derive it from a model or HTTP request.
func (*Service) CreateManagedImage ¶ added in v0.12.3
func (s *Service) CreateManagedImage( ctx context.Context, req ManagedImageRequest, recorder Recorder, ) (Record, error)
CreateManagedImage validates and atomically stores one generated image. If metadata persistence fails after the rename, the returned Record identifies the preserved orphan for diagnostics; it is intentionally not removed and not published into the in-memory registry.
func (*Service) ListManaged ¶ added in v0.12.3
ListManaged returns only content rooted under JCode's private managed storage. It intentionally accepts no workspace path, making it safe for an SSH/Docker task whose workspace path belongs to a different host.
func (*Service) Open ¶
func (s *Service) Open(ctx context.Context, sessionID, workspace, artifactID string) (Record, *os.File, error)
Open returns a read-only file descriptor constrained by os.Root. Unlike a validate-then-os.Open sequence, Root.Open prevents a concurrent symlink swap from redirecting the read outside the workspace.
type StorageKind ¶ added in v0.12.3
type StorageKind string
StorageKind identifies the trusted backend used for an artifact. The empty value is deliberately interpreted as workspace so records written by older JCode versions retain their original behavior.
const ( StorageWorkspace StorageKind = "workspace" StorageManaged StorageKind = "managed" )