Class MarketplaceStager
<wsRoot>/.skills-cache/<source-ns>/<skill-name>/ so that:
- shell-mode HarnessAgents (sandbox or Local-with-shell) can execute the staged scripts via absolute paths
- sandbox projection (which includes
.skills-cacheinDEFAULT_WORKSPACE_PROJECTION_ROOTS) hydrates the staged content into the sandbox at start time
The stager keeps no cross-call state: each invocation rebuilds the white-list of
directories that should remain under .skills-cache, materialises any files whose
SHA-256 has changed, and deletes orphan directories not present in the white-list.
The cache is shared. One stager instance serves every concurrent call against a
workspace root, and on a shared volume other replicas write into the same tree. A white-list
built from one call's visible skills therefore says nothing about what other in-flight calls
still need: with per-user skill visibility, call B's "orphan" is call A's live
filesRoot. Orphan GC is consequently gated on DEFAULT_ORPHAN_GRACE — a
directory is deleted only after sitting untouched for that long, and every retained directory
is touched on each pass — and every traversal tolerates entries deleted underneath it.
Workspace-native skills (those produced by WorkspaceSkillRepository) are NOT
staged: they already live under <wsRoot>/skills/ (or are produced lazily from the
sandbox-backed filesystem) and projection covers them through the regular skills
root.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordPairs a skill with the repository that produced it.static interfaceOutcome of staging one skill. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMarketplaceStager(Path workspaceRoot) MarketplaceStager(Path workspaceRoot, Duration orphanGrace) Overload for callers (and tests) that need a non-default orphan grace window. -
Method Summary
Modifier and TypeMethodDescriptionvoidConvenience for callers that don't care about return values.resolveSourceNamespaces(List<io.agentscope.core.skill.repository.AgentSkillRepository> repos) Resolves per-repositorysourcenamespaces.stage(List<MarketplaceStager.RepoBound> visible, Map<io.agentscope.core.skill.repository.AgentSkillRepository, String> sourceNs) Stage all eligible inputs and return a map fromskill.nameto its resolvedMarketplaceStager.StageResult.stage(List<MarketplaceStager.RepoBound> visible, Map<io.agentscope.core.skill.repository.AgentSkillRepository, String> sourceNs, String scope) Stages into this call's isolation scope.
-
Field Details
-
CACHE_DIR
- See Also:
-
GLOBAL_NAMESPACE
- See Also:
-
DEFAULT_ORPHAN_GRACE
How long an orphan must sit untouched before it may be deleted. The window has to outlast the longest call that could still shell out to a staged script, because a staged path is handed to the model in the system prompt and used much later in the call. Leaving a stale directory costs a few KB; deleting a live one breaks another user's call, so the default errs long. -
SHARED_SCOPE
Segment used when the caller has no isolation identity to key on.- See Also:
-
-
Constructor Details
-
MarketplaceStager
-
MarketplaceStager
Overload for callers (and tests) that need a non-default orphan grace window.
-
-
Method Details
-
stage
public Map<String,MarketplaceStager.StageResult> stage(List<MarketplaceStager.RepoBound> visible, Map<io.agentscope.core.skill.repository.AgentSkillRepository, String> sourceNs) Stage all eligible inputs and return a map fromskill.nameto its resolvedMarketplaceStager.StageResult. Inputs whose source repository is aWorkspaceSkillRepositoryare returned asMarketplaceStager.StageResult.WorkspaceNative— they need no staging because the workspace tree already contains them.The white-list of staged directories is rebuilt every call; any pre-existing directory under
.skills-cache/<source-ns>/not in the white-list is removed (cheap orphan GC: marketplace repos that no longer publish a given skill leave no residue).- Parameters:
visible- skill+repository pairs in compose order (winner per name already deduped upstream)sourceNs- map from repository identity to its resolved source namespace (handles repos with collidinggetSource()via_idxsuffix)- Returns:
- ordered map (insertion-order preserved) keyed by
skill.name
-
stage
public Map<String,MarketplaceStager.StageResult> stage(List<MarketplaceStager.RepoBound> visible, Map<io.agentscope.core.skill.repository.AgentSkillRepository, String> sourceNs, String scope) Stages into this call's isolation scope. Every directory GC may remove lives under.skills-cache/<scope>/, and only calls that share a scope share that subtree — so a white-list built from one call's visible skills is authoritative for everything it can reach, which is the property the flat layout never had.- Parameters:
scope- per-call isolation key (typicallyuserIdorsessionId); blank collapses to "_shared"
-
invalidateAll
public void invalidateAll()Convenience for callers that don't care about return values. -
resolveSourceNamespaces
public static Map<io.agentscope.core.skill.repository.AgentSkillRepository,String> resolveSourceNamespaces(List<io.agentscope.core.skill.repository.AgentSkillRepository> repos) Resolves per-repositorysourcenamespaces. When two repositories report the samegetSource(), the second and subsequent ones receive an_<idx>suffix (with a warning log). Layer-1 host repositories whose source string is empty getGLOBAL_NAMESPACE.
-