Skip to content
Merged
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
26 changes: 24 additions & 2 deletions action_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestActionGatewayPublicOperations(t *testing.T) {
ctx := context.Background()
operations := []operation{
{"Tools", "List", "GET", "/tools", "page=2&per_page=7&toolkit_id=exa", "", []interface{}{&ActionGatewayToolListOptions{ToolkitID: "exa", Page: 2, PerPage: 7}}},
{"Tools", "ListVersions", "GET", "/tools/exa/versions", "page_size=5&page_token=next", "", []interface{}{"exa", &ActionGatewayCursorOptions{PageSize: 5, PageToken: "next"}}},
{"Tools", "ListToolkits", "GET", "/tools/toolkits", "", "", nil},
{"Tools", "ListProviders", "GET", "/tools/providers", "", "", nil},
{"Tools", "Search", "GET", "/tools/search", "provider=a&provider=b&query=foo+bar", "", []interface{}{&ActionGatewayToolSearchOptions{Providers: []string{"a", "b"}, Query: "foo bar"}}},
Expand Down Expand Up @@ -80,8 +81,8 @@ func TestActionGatewayPublicOperations(t *testing.T) {
{"ActorLimits", "Set", "POST", "/actors/alice/limits:set", "", `{"overrides":[{"category":"LIMIT_CATEGORY_WEB_SEARCH_REQUESTS_PER_MINUTE","requests_per_minute":"10"}]}`, []interface{}{"alice", &ActionGatewaySetLimitsRequest{Overrides: []ActionGatewayLimitOverride{{Category: "LIMIT_CATEGORY_WEB_SEARCH_REQUESTS_PER_MINUTE", RequestsPerMinute: "10"}}}}},
{"ActorLimits", "Clear", "POST", "/actors/alice/limits:clear", "", `{"categories":["LIMIT_CATEGORY_WEB_SEARCH_REQUESTS_PER_MINUTE"]}`, []interface{}{"alice", &ActionGatewayClearLimitsRequest{Categories: []string{"LIMIT_CATEGORY_WEB_SEARCH_REQUESTS_PER_MINUTE"}}}},
}
if len(operations) != 59 {
t.Fatalf("expected all 59 public operations, got %d", len(operations))
if len(operations) != 60 {
t.Fatalf("expected all 60 public operations, got %d", len(operations))
}
for _, operation := range operations {
t.Run(operation.resource+"/"+operation.name, func(t *testing.T) {
Expand Down Expand Up @@ -345,3 +346,24 @@ func TestActionGatewayProviderCredentialWireShapes(t *testing.T) {
t.Fatalf("delete = %+v, %v", deleted, err)
}
}

func TestActionGatewayToolsListVersionsDecodesChangelog(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
if request.URL.EscapedPath() != actionGatewayPath+"/tools/a%2Fb/versions" {
t.Errorf("path = %s", request.URL.EscapedPath())
}
writer.Header().Set("Content-Type", "application/json")
_, _ = io.WriteString(writer, `{"versions":[{"tool_slug":"exa","version":"v2","released_at":"2026-11-12T09:30:00Z","latest":true,"previous_version":"v1","breaking":true,"changes":[{"type":"requiredScopesAdded","values":["read"],"breaking":true}]}],"next_page_token":"n"}`)
}))
defer server.Close()
client := NewClient(server.Client())
client.BaseURL, _ = url.Parse(server.URL)
got, _, err := client.ActionGateway.Tools.ListVersions(context.Background(), "a/b", nil)
if err != nil {
t.Fatal(err)
}
want := ActionGatewayToolVersionRelease{ToolSlug: "exa", Version: "v2", ReleasedAt: got.Versions[0].ReleasedAt, Latest: true, PreviousVersion: "v1", Breaking: true, Changes: []ActionGatewayToolVersionChange{{Type: "requiredScopesAdded", Values: []string{"read"}, Breaking: true}}}
if len(got.Versions) != 1 || !reflect.DeepEqual(got.Versions[0], want) || got.NextPageToken != "n" || got.Versions[0].ReleasedAt == nil {
t.Fatalf("response = %+v", got)
}
}
39 changes: 39 additions & 0 deletions action_gateway_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,35 @@ type ActionGatewayGetToolHealthResponse struct {
History *ActionGatewayHealthHistory `json:"history"`
}

// ActionGatewayToolVersionChange is one difference from the previous released
// version of a tool. Type is one of the change types in the API reference, such
// as "inputPropertyAdded" or "requiredScopesAdded".
type ActionGatewayToolVersionChange struct {
Type string `json:"type"`
Path string `json:"path,omitempty"`
Values []string `json:"values,omitempty"`
Breaking bool `json:"breaking"`
}

// ActionGatewayToolVersionRelease is one released version of a catalog tool.
// Pin it by calling the tool as "<ToolSlug>@<Version>".
type ActionGatewayToolVersionRelease struct {
ToolSlug string `json:"tool_slug"`
Version string `json:"version"`
ReleasedAt *Timestamp `json:"released_at,omitempty"`
Latest bool `json:"latest"`
PreviousVersion string `json:"previous_version,omitempty"`
Breaking bool `json:"breaking"`
Changes []ActionGatewayToolVersionChange `json:"changes,omitempty"`
}

// ActionGatewayToolVersionsResponse is one page of a tool's released versions,
// newest first.
type ActionGatewayToolVersionsResponse struct {
Versions []ActionGatewayToolVersionRelease `json:"versions"`
NextPageToken string `json:"next_page_token,omitempty"`
}

// List retrieves a page of catalog tools.
func (s *ActionGatewayToolsService) List(ctx context.Context, opt *ActionGatewayToolListOptions) (*ActionGatewayToolsResponse, *Response, error) {
return actionGatewayRequest[ActionGatewayToolsResponse](ctx, s.client, http.MethodGet, actionGatewayPath+"/tools", opt, nil)
Expand Down Expand Up @@ -403,3 +432,13 @@ func (s *ActionGatewayToolsService) GetHealth(ctx context.Context, slug string,
}
return actionGatewayRequest[ActionGatewayGetToolHealthResponse](ctx, s.client, http.MethodGet, path, opt, nil)
}

// ListVersions retrieves a page of a catalog tool's released versions, newest
// first, each with its changes from the previous release.
func (s *ActionGatewayToolsService) ListVersions(ctx context.Context, slug string, opt *ActionGatewayCursorOptions) (*ActionGatewayToolVersionsResponse, *Response, error) {
path, err := actionGatewayItem(actionGatewayPath+"/tools", actionGatewayPathPart{"slug", slug})
if err != nil {
return nil, nil, err
}
return actionGatewayRequest[ActionGatewayToolVersionsResponse](ctx, s.client, http.MethodGet, path+"/versions", opt, nil)
}
Loading