| 164 | } |
| 165 | |
| 166 | func (t *resourceNoteTool) Execute(ctx context.Context, input map[string]any, tc *tools.ToolContext) (any, error) { |
| 167 | note, _ := input["note"].(string) |
| 168 | if note == "" { |
| 169 | return nil, errors.New("note is required") |
| 170 | } |
| 171 | |
| 172 | scope := memory.Scope{ |
| 173 | UserID: t.userID, |
| 174 | ProjectID: t.projectID, |
| 175 | ResourceType: t.resourceType, |
| 176 | ResourceID: t.resourceID, |
| 177 | Shared: t.shared, |
| 178 | } |
| 179 | ns := scope.Namespace() |
| 180 | |
| 181 | payload := map[string]any{ |
| 182 | "file": "notes.md", |
| 183 | "namespace": ns, |
| 184 | "mode": "append", |
| 185 | "title": "Resource note", |
| 186 | "content": note, |
| 187 | } |
| 188 | |
| 189 | return t.memoryWrite.Execute(ctx, payload, tc) |
| 190 | } |
| 191 | |
| 192 | func (t *resourceNoteTool) Prompt() string { |
| 193 | return `Use this tool to write notes about a specific resource (article, novel, song, PPT, etc.). The tool will choose a stable namespace and filename; you only need to focus on the note content.` |