fix(compaction): add checkpoint store for session agent config
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
export type CompactionAgentConfigCheckpoint = {
|
||||||
|
agent?: string
|
||||||
|
model?: { providerID: string; modelID: string }
|
||||||
|
tools?: Record<string, boolean>
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkpoints = new Map<string, CompactionAgentConfigCheckpoint>()
|
||||||
|
|
||||||
|
function cloneCheckpoint(
|
||||||
|
checkpoint: CompactionAgentConfigCheckpoint,
|
||||||
|
): CompactionAgentConfigCheckpoint {
|
||||||
|
return {
|
||||||
|
...(checkpoint.agent ? { agent: checkpoint.agent } : {}),
|
||||||
|
...(checkpoint.model
|
||||||
|
? {
|
||||||
|
model: {
|
||||||
|
providerID: checkpoint.model.providerID,
|
||||||
|
modelID: checkpoint.model.modelID,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...(checkpoint.tools ? { tools: { ...checkpoint.tools } } : {}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setCompactionAgentConfigCheckpoint(
|
||||||
|
sessionID: string,
|
||||||
|
checkpoint: CompactionAgentConfigCheckpoint,
|
||||||
|
): void {
|
||||||
|
checkpoints.set(sessionID, cloneCheckpoint(checkpoint))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCompactionAgentConfigCheckpoint(
|
||||||
|
sessionID: string,
|
||||||
|
): CompactionAgentConfigCheckpoint | undefined {
|
||||||
|
const checkpoint = checkpoints.get(sessionID)
|
||||||
|
return checkpoint ? cloneCheckpoint(checkpoint) : undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clearCompactionAgentConfigCheckpoint(sessionID: string): void {
|
||||||
|
checkpoints.delete(sessionID)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user