Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
feat(sdk/go): expose set_tags on the filesystem client (#2782)
Evo241c7fb0ce82
diff --git a/sdk/go/README.md b/sdk/go/README.mdindex 28dbf2407..ad6a30b58 100644--- a/sdk/go/README.md+++ b/sdk/go/README.md@@ -111,7 +111,7 @@ Implemented:| Resource and skill import | `AddResource`, `AddSkill`, `WaitProcessed` || Skill management | `ListSkills`, `FindSkills`, `ValidateSkill`, `GetSkill`, `UpdateSkill`, `DeleteSkill` || Watch management | `ListWatches`, `GetWatch`, `UpdateWatch`, `DeleteWatch`, `TriggerWatch` |-| Filesystem and content | `List`, `Tree`, `Stat`, `Mkdir`, `Remove`, `Move`, `Read`, `Abstract`, `Overview`, `Write`, `Reindex` |+| Filesystem and content | `List`, `Tree`, `Stat`, `Mkdir`, `Remove`, `Move`, `Read`, `Abstract`, `Overview`, `Write`, `SetTags`, `Reindex` || Retrieval | `Find`, `Search`, `Grep`, `Glob` || Sessions and tasks | `CreateSession`, `ListSessions`, `GetSession`, `SessionExists`, `GetSessionContext`, `GetSessionArchive`, `DeleteSession`, `AddMessage`, `BatchAddMessages`, `CommitSession`, `GetTask`, `ListTasks` || Packs | `ExportOVPack`, `BackupOVPack`, `ImportOVPack`, `RestoreOVPack` |diff --git a/sdk/go/README_CN.md b/sdk/go/README_CN.mdindex 9576fae52..97eedd754 100644--- a/sdk/go/README_CN.md+++ b/sdk/go/README_CN.md@@ -40,7 +40,7 @@ Go SDK 仅支持 HTTP 模式,不支持 Python embedded 模式,也不保留| 资源和技能导入 | `AddResource`, `AddSkill`, `WaitProcessed` || 技能管理 | `ListSkills`, `FindSkills`, `ValidateSkill`, `GetSkill`, `UpdateSkill`, `DeleteSkill` || Watch 管理 | `ListWatches`, `GetWatch`, `UpdateWatch`, `DeleteWatch`, `TriggerWatch` |-| 文件系统和内容 | `List`, `Tree`, `Stat`, `Mkdir`, `Remove`, `Move`, `Read`, `Abstract`, `Overview`, `Write`, `Reindex` |+| 文件系统和内容 | `List`, `Tree`, `Stat`, `Mkdir`, `Remove`, `Move`, `Read`, `Abstract`, `Overview`, `Write`, `SetTags`, `Reindex` || 检索 | `Find`, `Search`, `Grep`, `Glob` || 会话和任务 | `CreateSession`, `ListSessions`, `GetSession`, `SessionExists`, `GetSessionContext`, `GetSessionArchive`, `DeleteSession`, `AddMessage`, `BatchAddMessages`, `CommitSession`, `GetTask`, `ListTasks` || OVPack | `ExportOVPack`, `BackupOVPack`, `ImportOVPack`, `RestoreOVPack` |diff --git a/sdk/go/client_test.go b/sdk/go/client_test.goindex a80b74fa0..255a408ba 100644--- a/sdk/go/client_test.go+++ b/sdk/go/client_test.go@@ -661,3 +661,73 @@ func TestHealth(t *testing.T) {t.Fatal("expected healthy")}}++func TestSetTagsSendsBody(t *testing.T) {+ client, closeServer := testClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path != "/api/v1/content/set_tags" {+ t.Fatalf("path = %s", r.URL.Path)+ }+ if r.Method != http.MethodPost {+ t.Fatalf("method = %s", r.Method)+ }+ body := readJSONBody(t, r)+ if got := body["uri"]; got != "viking://resources/docs" {+ t.Fatalf("uri = %#v", got)+ }+ tags, ok := body["tags"].([]any)+ if !ok || len(tags) != 2 || tags[0] != "team=infra" || tags[1] != "tier=gold" {+ t.Fatalf("tags = %#v", body["tags"])+ }+ if got := body["mode"]; got != "append" {+ t.Fatalf("mode = %#v", got)+ }+ if got := body["recursive"]; got != true {+ t.Fatalf("recursive = %#v", got)+ }+ if got := body["telemetry"]; got != true {+ t.Fatalf("telemetry = %#v", got)+ }+ writeOK(t, w, map[string]any{"updated": 3})+ }))+ defer closeServer()++ result, err := client.SetTags(context.Background(), "resources/docs", []string{"team=infra", "tier=gold"}, &SetTagsOptions{+ Mode: "append",+ Recursive: true,+ Telemetry: true,+ })+ if err != nil {+ t.Fatal(err)+ }+ if got := result["updated"]; got != float64(3) {+ t.Fatalf("updated = %#v", got)+ }+}++func TestSetTagsDefaultsModeAndOmitsTelemetry(t *testing.T) {+ client, closeServer := testClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path != "/api/v1/content/set_tags" {+ t.Fatalf("path = %s", r.URL.Path)+ }+ body := readJSONBody(t, r)+ if got := body["mode"]; got != "replace" {+ t.Fatalf("default mode = %#v", got)+ }+ if got := body["recursive"]; got != false {+ t.Fatalf("recursive = %#v", got)+ }+ // nil tags must serialize as an empty JSON array, not null, to satisfy+ // the server's tags:list[str] contract.+ tags, ok := body["tags"].([]any)+ if !ok || len(tags) != 0 {+ t.Fatalf("tags = %#v (want empty array)", body["tags"])+ }+ requireBodyKeysAbsent(t, body, "telemetry")+ writeOK(t, w, map[string]any{"updated": 1})+ }))+ defer closeServer()++ if _, err := client.SetTags(context.Background(), "resources/docs/readme.md", nil, nil); err != nil {+ t.Fatal(err)+ }+}diff --git a/sdk/go/filesystem.go b/sdk/go/filesystem.goindex ca003d7c3..246890a29 100644--- a/sdk/go/filesystem.go+++ b/sdk/go/filesystem.go@@ -151,6 +151,35 @@ func (c *Client) Write(ctx context.Context, uri string, content string, opts *Wrreturn result, err}+// SetTags sets explicit k=v retrieval tags metadata for a file or directory.+// Valid modes are "replace" (default) and "append"; Recursive applies the tags+// to every file under a directory URI.+func (c *Client) SetTags(ctx context.Context, uri string, tags []string, opts *SetTagsOptions) (map[string]any, error) {+ if opts == nil {+ opts = &SetTagsOptions{Mode: "replace"}+ }+ mode := opts.Mode+ if mode == "" {+ mode = "replace"+ }+ // The server contract is tags:list[str]; a nil slice would marshal to JSON+ // null and fail validation, so normalize to an empty list. With mode+ // "replace" an empty list clears all tags.+ if tags == nil {+ tags = []string{}+ }+ payload := map[string]any{+ "uri": NormalizeURI(uri),+ "tags": tags,+ "mode": mode,+ "recursive": opts.Recursive,+ }+ setAny(payload, "telemetry", opts.Telemetry)+ var result map[string]any+ err := c.doJSON(ctx, http.MethodPost, "/api/v1/content/set_tags", nil, payload, &result)+ return result, err+}+// Reindex triggers reindexing for a URI.func (c *Client) Reindex(ctx context.Context, uri string, opts *ReindexOptions) (map[string]any, error) {if opts == nil {diff --git a/sdk/go/types.go b/sdk/go/types.goindex ba910bd01..91853a007 100644--- a/sdk/go/types.go+++ b/sdk/go/types.go@@ -142,6 +142,13 @@ type WriteOptions struct {Telemetry any}+// SetTagsOptions controls SetTags.+type SetTagsOptions struct {+ Mode string+ Recursive bool+ Telemetry any+}+// ReindexOptions controls Reindex.type ReindexOptions struct {Mode string