MCPcopy Create free account
hub / github.com/compozy/agh / ReadMemory

Method ReadMemory

internal/api/core/memory.go:289–320  ·  view source on GitHub ↗

ReadMemory returns one memory document.

(c *gin.Context)

Source from the content-addressed store, hash-verified

287
288// ReadMemory returns one memory document.
289func (h *BaseHandlers) ReadMemory(c *gin.Context) {
290 selector := memorySelectorFromQuery(c)
291 location, err := h.resolveMemoryLocation(c.Request.Context(), c.Param("filename"), selector)
292 if err != nil {
293 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
294 return
295 }
296 if !selector.IncludeSystem && memorySystemManaged(location.Filename) {
297 err := fmt.Errorf("%w: memory %q not found", os.ErrNotExist, location.Filename)
298 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
299 return
300 }
301
302 store, err := h.memoryStoreForLocation(c.Request.Context(), location)
303 if err != nil {
304 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
305 return
306 }
307
308 content, err := store.Read(location.Scope, c.Param("filename"))
309 if err != nil {
310 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
311 return
312 }
313 entry, err := h.memoryEntryPayload(store, location, content)
314 if err != nil {
315 h.respondMemoryError(c, StatusForMemoryError(err), err, nil)
316 return
317 }
318
319 c.JSON(http.StatusOK, contract.MemoryEntryResponse{Memory: entry})
320}
321
322// WriteMemory creates or proposes one Memory v2 entry.
323func (h *BaseHandlers) WriteMemory(c *gin.Context) {

Callers

nothing calls this directly

Calls 8

resolveMemoryLocationMethod · 0.95
respondMemoryErrorMethod · 0.95
memoryEntryPayloadMethod · 0.95
memorySelectorFromQueryFunction · 0.85
StatusForMemoryErrorFunction · 0.85
memorySystemManagedFunction · 0.85
ReadMethod · 0.65

Tested by

no test coverage detected