()
| 159 | } |
| 160 | |
| 161 | func (p *SkillPersistence) ExportSnapshot() map[string]any { |
| 162 | if p == nil { |
| 163 | return nil |
| 164 | } |
| 165 | p.mu.Lock() |
| 166 | defer p.mu.Unlock() |
| 167 | scopes := map[string]any{} |
| 168 | for scope, records := range p.records { |
| 169 | scopeRecords := map[string]any{} |
| 170 | for name, record := range records { |
| 171 | scopeRecords[name] = map[string]any{ |
| 172 | "name": record.Name, |
| 173 | "path": record.Path, |
| 174 | "content": record.Content, |
| 175 | "invoked_at": record.InvokedAt, |
| 176 | "agent_scope": record.AgentScope, |
| 177 | "last_turn_index": record.LastTurnIndex, |
| 178 | "invocation_count": record.InvocationCount, |
| 179 | } |
| 180 | } |
| 181 | scopes[scope] = scopeRecords |
| 182 | } |
| 183 | return map[string]any{ |
| 184 | "version": SkillRecoverySnapshotVersion, |
| 185 | "agent_scopes": scopes, |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | func (p *SkillPersistence) ImportSnapshot(snapshot map[string]any) { |
| 190 | if p == nil { |
no outgoing calls