MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / orderedAgentStateSnapshot

Function orderedAgentStateSnapshot

session/store.go:608–635  ·  view source on GitHub ↗
(state *agent.AgentState)

Source from the content-addressed store, hash-verified

606
607func atomicWriteJSONL(path string, records []map[string]any) error {
608 var data []byte
609 for _, record := range records {
610 line, err := marshalPythonJSON(record, false)
611 if err != nil {
612 return err
613 }
614 line = spacePythonJSONSeparators(line)
615 data = append(data, line...)
616 data = append(data, '\n')
617 }
618 return atomicReplace(path, data)
619}
620
621func atomicReplace(path string, data []byte) error {
622 return apppaths.WriteFileAtomic(path, data, 0o600)
623}
624
625func newGenerationID() string {
626 return strings.ReplaceAll(uuid.NewString(), "-", "")
627}
628
629func newOrderedJSONMap() *orderedmap.OrderedMap[string, any] {
630 return orderedmap.New[string, any](orderedmap.WithDisableHTMLEscape[string, any]())
631}
632
633func setOrderedMapValues(target *orderedmap.OrderedMap[string, any], values map[string]any) {
634 keys := make([]string, 0, len(values))
635 for key := range values {
636 keys = append(keys, key)
637 }
638 sort.Strings(keys)

Callers 1

SaveStateWithRecoveryMethod · 0.85

Calls 5

intSetToSliceFunction · 0.85
newOrderedJSONMapFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected