feat: add file tools (read/write/edit/list_dir) for agent memory writes
Enable the agent to persist memories by adding 4 SPIFFS file tools (read_file, write_file, edit_file, list_dir) with path validation, and update the system prompt with memory guidelines pointing to /spiffs/memory/MEMORY.md and daily notes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
28
main/tools/tool_files.h
Normal file
28
main/tools/tool_files.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* Read a file from SPIFFS.
|
||||
* Input JSON: {"path": "/spiffs/..."}
|
||||
*/
|
||||
esp_err_t tool_read_file_execute(const char *input_json, char *output, size_t output_size);
|
||||
|
||||
/**
|
||||
* Write/overwrite a file on SPIFFS.
|
||||
* Input JSON: {"path": "/spiffs/...", "content": "..."}
|
||||
*/
|
||||
esp_err_t tool_write_file_execute(const char *input_json, char *output, size_t output_size);
|
||||
|
||||
/**
|
||||
* Find-and-replace edit a file on SPIFFS.
|
||||
* Input JSON: {"path": "/spiffs/...", "old_string": "...", "new_string": "..."}
|
||||
*/
|
||||
esp_err_t tool_edit_file_execute(const char *input_json, char *output, size_t output_size);
|
||||
|
||||
/**
|
||||
* List files on SPIFFS, optionally filtered by path prefix.
|
||||
* Input JSON: {"prefix": "/spiffs/..."} (prefix is optional)
|
||||
*/
|
||||
esp_err_t tool_list_dir_execute(const char *input_json, char *output, size_t output_size);
|
||||
Reference in New Issue
Block a user