๐ Context-sync API Reference
April 29, 2026 ยท View on GitHub
Overview
Context Sync provides a mechanism to persist files and directories across sessions by synchronizing local paths to a named context. It supports policies for upload/download behavior and selective path inclusion.
๐ Tutorial
Learn how context synchronization works and how to persist data across sessions
ContextSync
Defines the context synchronization configuration.
This class configures how a context should be synchronized with a session, including the context ID, mount path, synchronization policy, and whether to wait for initial download completion.
Constructor
public ContextSync()
public ContextSync(String contextId, String path, SyncPolicy policy)
Methods
create
public static ContextSync create(String contextId, String path, SyncPolicy policy)
withPolicy
public ContextSync withPolicy(SyncPolicy policy)
withBetaWaitForCompletion
public ContextSync withBetaWaitForCompletion(Boolean wait)
getPolicy
public SyncPolicy getPolicy()
setPolicy
public void setPolicy(SyncPolicy policy)
getBetaWaitForCompletion
public Boolean getBetaWaitForCompletion()
setBetaWaitForCompletion
public void setBetaWaitForCompletion(Boolean betaWaitForCompletion)
SyncPolicy
Defines the synchronization policy
Attributes: - uploadPolicy: Defines the upload policy - downloadPolicy: Defines the download policy - deletePolicy: Defines the delete policy - extractPolicy: Defines the extract policy - recyclePolicy: Defines the recycle policy - bwList: Defines the black and white list
Constructor
public SyncPolicy()
public SyncPolicy(UploadPolicy uploadPolicy, DownloadPolicy downloadPolicy, DeletePolicy deletePolicy, ExtractPolicy extractPolicy, BWList bwList)
public SyncPolicy(UploadPolicy uploadPolicy, DownloadPolicy downloadPolicy, DeletePolicy deletePolicy, ExtractPolicy extractPolicy, RecyclePolicy recyclePolicy, BWList bwList)
Methods
defaultPolicy
public static SyncPolicy defaultPolicy()
getUploadPolicy
public UploadPolicy getUploadPolicy()
setUploadPolicy
public void setUploadPolicy(UploadPolicy uploadPolicy)
getDownloadPolicy
public DownloadPolicy getDownloadPolicy()
setDownloadPolicy
public void setDownloadPolicy(DownloadPolicy downloadPolicy)
getDeletePolicy
public DeletePolicy getDeletePolicy()
setDeletePolicy
public void setDeletePolicy(DeletePolicy deletePolicy)
getExtractPolicy
public ExtractPolicy getExtractPolicy()
setExtractPolicy
public void setExtractPolicy(ExtractPolicy extractPolicy)
getRecyclePolicy
public RecyclePolicy getRecyclePolicy()
setRecyclePolicy
public void setRecyclePolicy(RecyclePolicy recyclePolicy)
getBwList
public BWList getBwList()
setBwList
public void setBwList(BWList bwList)
UploadPolicy
Defines the upload policy for context synchronization
Attributes: autoUpload: Enables automatic upload uploadStrategy: Defines the upload strategy uploadMode: Defines the upload mode (UploadMode.FILE or UploadMode.ARCHIVE) period: Upload period in seconds (default: 30) archiveExcludePaths: When uploadMode is ARCHIVE, paths to upload as individual files
Constructor
public UploadPolicy()
public UploadPolicy(boolean autoUpload, UploadStrategy uploadStrategy, Integer period)
public UploadPolicy(boolean autoUpload, UploadStrategy uploadStrategy, UploadMode uploadMode, Integer period)
Methods
defaultPolicy
public static UploadPolicy defaultPolicy()
isAutoUpload
public boolean isAutoUpload()
setAutoUpload
public void setAutoUpload(boolean autoUpload)
getUploadStrategy
public UploadStrategy getUploadStrategy()
setUploadStrategy
public void setUploadStrategy(UploadStrategy uploadStrategy)
getPeriod
public Integer getPeriod()
setPeriod
public void setPeriod(Integer period)
getUploadMode
public UploadMode getUploadMode()
setUploadMode
public void setUploadMode(UploadMode uploadMode)
getArchiveExcludePaths
public List<String> getArchiveExcludePaths()
setArchiveExcludePaths
public void setArchiveExcludePaths(List<String> archiveExcludePaths)
DownloadPolicy
Defines the download policy for context synchronization
Attributes: autoDownload: Enables automatic download downloadStrategy: Defines the download strategy
Constructor
public DownloadPolicy()
public DownloadPolicy(boolean autoDownload, DownloadStrategy downloadStrategy)
Methods
defaultPolicy
public static DownloadPolicy defaultPolicy()
isAutoDownload
public boolean isAutoDownload()
setAutoDownload
public void setAutoDownload(boolean autoDownload)
getDownloadStrategy
public DownloadStrategy getDownloadStrategy()
setDownloadStrategy
public void setDownloadStrategy(DownloadStrategy downloadStrategy)
DeletePolicy
Defines the delete policy for context synchronization
Attributes: syncLocalFile: Enables synchronization of local file deletions
Constructor
public DeletePolicy()
public DeletePolicy(boolean syncLocalFile)
Methods
defaultPolicy
public static DeletePolicy defaultPolicy()
isSyncLocalFile
public boolean isSyncLocalFile()
setSyncLocalFile
public void setSyncLocalFile(boolean syncLocalFile)
ExtractPolicy
Defines the extract policy for context synchronization
Attributes: extract: Enables file extraction deleteSrcFile: Enables deletion of source file after extraction extractCurrentFolder: Enables extraction to current folder
Constructor
public ExtractPolicy()
public ExtractPolicy(boolean extract, boolean deleteSrcFile, boolean extractCurrentFolder)
Methods
defaultPolicy
public static ExtractPolicy defaultPolicy()
isExtract
public boolean isExtract()
setExtract
public void setExtract(boolean extract)
isDeleteSrcFile
public boolean isDeleteSrcFile()
setDeleteSrcFile
public void setDeleteSrcFile(boolean deleteSrcFile)
isExtractCurrentFolder
public boolean isExtractCurrentFolder()
setExtractCurrentFolder
public void setExtractCurrentFolder(boolean extractCurrentFolder)
RecyclePolicy
Defines the recycle policy for context synchronization
Attributes: lifecycle: Defines how long the context data should be retained Available options: - LIFECYCLE_1DAY: Keep data for 1 day - LIFECYCLE_3DAYS: Keep data for 3 days - LIFECYCLE_5DAYS: Keep data for 5 days - LIFECYCLE_10DAYS: Keep data for 10 days - LIFECYCLE_15DAYS: Keep data for 15 days - LIFECYCLE_30DAYS: Keep data for 30 days - LIFECYCLE_90DAYS: Keep data for 90 days - LIFECYCLE_180DAYS: Keep data for 180 days - LIFECYCLE_360DAYS: Keep data for 360 days - LIFECYCLE_FOREVER: Keep data permanently (default) paths: Specifies which directories or files should be subject to the recycle policy Rules: - Must use exact directory/file paths - Wildcard patterns (* ? [ ]) are NOT supported - Empty string "" means apply to all paths in the context - Multiple paths can be specified as a list Default: [""] (applies to all paths)
Constructor
public RecyclePolicy()
public RecyclePolicy(Lifecycle lifecycle, List<String> paths)
Methods
defaultPolicy
public static RecyclePolicy defaultPolicy()
Creates a new recycle policy with default values
Returns:
RecyclePolicy: RecyclePolicy with default values
getLifecycle
public Lifecycle getLifecycle()
setLifecycle
public void setLifecycle(Lifecycle lifecycle)
getPaths
public List<String> getPaths()
setPaths
public void setPaths(List<String> paths)
WhiteList
Defines the white list configuration
Attributes: path: Path to include in the white list. When isPathRegex is false (default), this must be an exact absolute directory path and wildcard characters are not allowed. When isPathRegex is true, this is treated as a regex pattern (e.g. "/home/wuying/.*"). excludePaths: Paths to exclude from the white list. When isExcludeRegex is false (default), these must be relative directory paths and wildcard characters are not allowed. When isExcludeRegex is true, these are treated as regex patterns. NOTE: exclude paths are RELATIVE to the white-listed path, not absolute. isPathRegex: If true, path is interpreted as a regex pattern. If false (default), path is an absolute directory path. isExcludeRegex: If true, excludePaths entries are interpreted as regex patterns. If false (default), excludePaths entries are relative directory paths.
Constructor
public WhiteList()
public WhiteList(String path, List<String> excludePaths)
public WhiteList(String path, List<String> excludePaths, boolean isPathRegex, boolean isExcludeRegex)
Methods
getExcludePaths
public List<String> getExcludePaths()
setExcludePaths
public void setExcludePaths(List<String> excludePaths)
isPathRegex
public boolean isPathRegex()
setPathRegex
public void setPathRegex(boolean isPathRegex)
isExcludeRegex
public boolean isExcludeRegex()
setExcludeRegex
public void setExcludeRegex(boolean isExcludeRegex)
BWList
Defines the black and white list configuration
Attributes: whiteLists: Defines the white lists
Constructor
public BWList()
public BWList(List<WhiteList> whiteLists)
Methods
getWhiteLists
public List<WhiteList> getWhiteLists()
setWhiteLists
public void setWhiteLists(List<WhiteList> whiteLists)