MCPcopy Create free account
hub / github.com/ByteYellow/AgentProvenance / readMessageBody

Function readMessageBody

internal/intent/contract.go:152–174  ·  view source on GitHub ↗

readMessageBody fetches an objectified agent-message body (content-addressed on disk) and returns its text.

(db *sql.DB, hash string)

Source from the content-addressed store, hash-verified

150// readMessageBody fetches an objectified agent-message body (content-addressed on
151// disk) and returns its text.
152func readMessageBody(db *sql.DB, hash string) string {
153 var path string
154 if err := db.QueryRow(`SELECT path FROM provenance_objects WHERE hash = ?`, hash).Scan(&path); err != nil {
155 return ""
156 }
157 raw, err := os.ReadFile(path)
158 if err != nil {
159 return ""
160 }
161 var obj struct {
162 Payload struct {
163 Body string `json:"body"`
164 Content string `json:"content"`
165 } `json:"payload"`
166 }
167 if err := json.Unmarshal(raw, &obj); err != nil {
168 return ""
169 }
170 if obj.Payload.Body != "" {
171 return obj.Payload.Body
172 }
173 return obj.Payload.Content
174}

Callers 1

extractMessageContractsFunction · 0.85

Calls 1

ReadFileMethod · 0.80

Tested by

no test coverage detected