Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions sdk/go/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func TestFindSendsHeadersQueryAndBody(t *testing.T) {
if !ok || len(levels) != 2 || levels[0] != float64(0) || levels[1] != float64(2) {
t.Fatalf("level = %#v", body["level"])
}
tags, ok := body["tags"].([]any)
if !ok || len(tags) != 2 || tags[0] != "project-x" || tags[1] != "draft" {
t.Fatalf("tags = %#v", body["tags"])
}
writeOK(t, w, map[string]any{
"resources": []map[string]any{
{"uri": "viking://resources/docs/api.md", "context_type": "resource", "score": 0.9},
Expand All @@ -139,6 +143,7 @@ func TestFindSendsHeadersQueryAndBody(t *testing.T) {
Until: "2026-06-18",
TimeField: "created_at",
Level: []int{0, 2},
Tags: []string{"project-x", "draft"},
})
if err != nil {
t.Fatal(err)
Expand All @@ -154,7 +159,7 @@ func TestFindOmitsSearchFiltersWhenUnset(t *testing.T) {
t.Fatalf("path = %s", r.URL.Path)
}
body := readJSONBody(t, r)
requireBodyKeysAbsent(t, body, "since", "until", "time_field", "level")
requireBodyKeysAbsent(t, body, "since", "until", "time_field", "level", "tags")
writeOK(t, w, map[string]any{"resources": []any{}})
}))
defer closeServer()
Expand Down Expand Up @@ -195,6 +200,10 @@ func TestSearchSendsSessionAndSearchFilters(t *testing.T) {
if !ok || len(levels) != 1 || levels[0] != float64(2) {
t.Fatalf("level = %#v", body["level"])
}
tags, ok := body["tags"].([]any)
if !ok || len(tags) != 1 || tags[0] != "project-x" {
t.Fatalf("tags = %#v", body["tags"])
}
writeOK(t, w, map[string]any{"resources": []any{}})
}))
defer closeServer()
Expand All @@ -206,6 +215,7 @@ func TestSearchSendsSessionAndSearchFilters(t *testing.T) {
Until: "2026-06-18",
TimeField: "updated_at",
Level: []int{2},
Tags: []string{"project-x"},
}); err != nil {
t.Fatal(err)
}
Expand All @@ -217,7 +227,7 @@ func TestSearchOmitsSearchFiltersWhenUnset(t *testing.T) {
t.Fatalf("path = %s", r.URL.Path)
}
body := readJSONBody(t, r)
requireBodyKeysAbsent(t, body, "since", "until", "time_field", "level")
requireBodyKeysAbsent(t, body, "since", "until", "time_field", "level", "tags")
writeOK(t, w, map[string]any{"resources": []any{}})
}))
defer closeServer()
Expand Down
6 changes: 6 additions & 0 deletions sdk/go/retrieval.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func (c *Client) Find(ctx context.Context, queryText string, opts *FindOptions)
if len(opts.Level) > 0 {
payload["level"] = opts.Level
}
if len(opts.Tags) > 0 {
payload["tags"] = opts.Tags
}
setAny(payload, "telemetry", opts.Telemetry)
var result FindResult
err := c.doJSON(ctx, http.MethodPost, "/api/v1/search/find", nil, payload, &result)
Expand Down Expand Up @@ -66,6 +69,9 @@ func (c *Client) Search(ctx context.Context, queryText string, opts *SearchOptio
if len(opts.Level) > 0 {
payload["level"] = opts.Level
}
if len(opts.Tags) > 0 {
payload["tags"] = opts.Tags
}
setAny(payload, "telemetry", opts.Telemetry)
var result FindResult
err := c.doJSON(ctx, http.MethodPost, "/api/v1/search/search", nil, payload, &result)
Expand Down
2 changes: 2 additions & 0 deletions sdk/go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ type FindOptions struct {
Until string
TimeField string
Level []int
Tags []string
}

// SearchOptions controls Search.
Expand All @@ -177,6 +178,7 @@ type SearchOptions struct {
Until string
TimeField string
Level []int
Tags []string
}

// GrepOptions controls Grep.
Expand Down
Loading