Files
amcs/internal/store/tool_annotations.go
Hein db7b152852
Some checks failed
CI / build-and-test (push) Failing after -31m25s
refactor(store): replace project and skill models with generated models
* Update project creation and retrieval to use generated models
* Modify skill addition and listing to utilize generated models
* Refactor thought handling to incorporate generated models
* Adjust tool annotations to align with new model structure
* Update API calls in the UI to use new ResolveSpec-based endpoints
* Enhance stats retrieval logic to aggregate thought metadata
2026-04-26 12:56:32 +02:00

41 lines
1.1 KiB
Go

package store
import (
"context"
"fmt"
"git.warky.dev/wdevs/amcs/internal/generatedmodels"
)
func (db *DB) UpsertToolAnnotation(ctx context.Context, toolName, notes string) error {
_, err := db.pool.Exec(ctx, `
insert into tool_annotations (tool_name, notes)
values ($1, $2)
on conflict (tool_name) do update
set notes = excluded.notes,
updated_at = now()
`, toolName, notes)
if err != nil {
return fmt.Errorf("upsert tool annotation: %w", err)
}
return nil
}
func (db *DB) GetToolAnnotations(ctx context.Context) (map[string]string, error) {
rows, err := db.pool.Query(ctx, `select tool_name, notes from tool_annotations`)
if err != nil {
return nil, fmt.Errorf("get tool annotations: %w", err)
}
defer rows.Close()
annotations := make(map[string]string)
for rows.Next() {
var model generatedmodels.ModelPublicToolAnnotations
if err := rows.Scan(&model.ToolName, &model.Notes); err != nil {
return nil, fmt.Errorf("scan tool annotation: %w", err)
}
annotations[model.ToolName.String()] = model.Notes.String()
}
return annotations, rows.Err()
}