From 82f96447094f22aa9822b36ff8665b3c14ff04f3 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 24 Apr 2026 16:24:45 +0000
Subject: [PATCH 01/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index f3c3396..281961a 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-6bd8aeaf9c5b9629c1db5e9770e0e735b2c4fc3a4b9f2700b83a7201152088c4.yml
openapi_spec_hash: b4978a5083d3d075b52101297da89918
-config_hash: 6933f26e5db3cc830b92644a8db3b664
+config_hash: 7adda56db5cedcde41b1164cf721c4aa
From 2763780292758cbac65255da7a8c83d0cb1800a7 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 24 Apr 2026 16:25:56 +0000
Subject: [PATCH 02/29] feat(api): manual updates
---
.stats.yml | 6 +-
README.md | 51 +-
agent.go | 610 ++++++++
agent_test.go | 215 +++
aliases.go | 142 ++
api.md | 339 ++---
cellapproval.go => approval.go | 132 +-
cellthreadevent_test.go => approval_test.go | 27 +-
approvalgrant.go | 244 ++++
...textentry_test.go => approvalgrant_test.go | 61 +-
auth.go | 60 +-
auth_test.go | 4 +-
cell.go | 529 -------
cellapproval_test.go | 44 -
cellapprovalgrant.go | 185 ---
cellapprovalgrant_test.go | 69 -
cellconfig.go | 44 -
cellconnection.go | 169 ---
cellcontext.go | 240 ----
cellcontextentry.go | 144 --
cellevent.go | 145 --
cellevent_test.go | 67 -
celllog.go | 89 --
celllog_test.go | 43 -
cellmetadata.go | 56 -
cellsandbox.go | 206 ---
cellschedule.go | 304 ----
cellthread.go | 735 ----------
cellthreadapproval.go | 94 --
cellthreadapproval_test.go | 45 -
cellthreadapprovalgrant.go | 103 --
cellthreadapprovalgrant_test.go | 67 -
cellthreadevent.go | 155 --
cellthreadlog.go | 149 --
cellthreadlog_test.go | 44 -
celltool_test.go | 36 -
celltoolsource.go | 70 -
client.go | 42 +-
client_test.go | 16 +-
connection.go | 169 +++
cellconnection_test.go => connection_test.go | 20 +-
context.go | 319 +++++
context_test.go | 162 +++
credential.go | 46 +-
credential_test.go | 8 +-
environment.go | 61 -
environmentevent.go | 237 ----
environmentevent_test.go | 67 -
environmenttoolsource.go | 562 --------
environmentwebhook.go | 364 -----
event.go | 370 +++++
cell_test.go => event_test.go | 110 +-
fleet.go | 55 +
log.go | 179 +++
cellcontext_test.go => log_test.go | 20 +-
oauth_test.go | 2 +-
packages/pagination/pagination.go | 1260 ++++++++++++++++-
...olsource_test.go => paginationauto_test.go | 16 +-
...tadata_test.go => paginationmanual_test.go | 30 +-
sandbox.go | 204 +++
cellsandbox_test.go => sandbox_test.go | 32 +-
schedule.go | 251 ++++
cellschedule_test.go => schedule_test.go | 37 +-
shared/shared.go | 98 ++
thread.go | 725 ++++++++++
cellthread_test.go => thread_test.go | 75 +-
celltool.go => tool.go | 88 +-
cellconfig_test.go => tool_test.go | 4 +-
toolsource.go | 665 +++++++++
...nttoolsource_test.go => toolsource_test.go | 120 +-
usage_test.go | 6 +-
webhook.go | 355 +++++
environmentwebhook_test.go => webhook_test.go | 52 +-
73 files changed, 6725 insertions(+), 5825 deletions(-)
create mode 100644 agent.go
create mode 100644 agent_test.go
rename cellapproval.go => approval.go (53%)
rename cellthreadevent_test.go => approval_test.go (69%)
create mode 100644 approvalgrant.go
rename cellcontextentry_test.go => approvalgrant_test.go (60%)
delete mode 100644 cell.go
delete mode 100644 cellapproval_test.go
delete mode 100644 cellapprovalgrant.go
delete mode 100644 cellapprovalgrant_test.go
delete mode 100644 cellconfig.go
delete mode 100644 cellconnection.go
delete mode 100644 cellcontext.go
delete mode 100644 cellcontextentry.go
delete mode 100644 cellevent.go
delete mode 100644 cellevent_test.go
delete mode 100644 celllog.go
delete mode 100644 celllog_test.go
delete mode 100644 cellmetadata.go
delete mode 100644 cellsandbox.go
delete mode 100644 cellschedule.go
delete mode 100644 cellthread.go
delete mode 100644 cellthreadapproval.go
delete mode 100644 cellthreadapproval_test.go
delete mode 100644 cellthreadapprovalgrant.go
delete mode 100644 cellthreadapprovalgrant_test.go
delete mode 100644 cellthreadevent.go
delete mode 100644 cellthreadlog.go
delete mode 100644 cellthreadlog_test.go
delete mode 100644 celltool_test.go
delete mode 100644 celltoolsource.go
create mode 100644 connection.go
rename cellconnection_test.go => connection_test.go (80%)
create mode 100644 context.go
create mode 100644 context_test.go
delete mode 100644 environment.go
delete mode 100644 environmentevent.go
delete mode 100644 environmentevent_test.go
delete mode 100644 environmenttoolsource.go
delete mode 100644 environmentwebhook.go
create mode 100644 event.go
rename cell_test.go => event_test.go (51%)
create mode 100644 fleet.go
create mode 100644 log.go
rename cellcontext_test.go => log_test.go (77%)
rename celltoolsource_test.go => paginationauto_test.go (65%)
rename cellmetadata_test.go => paginationmanual_test.go (58%)
create mode 100644 sandbox.go
rename cellsandbox_test.go => sandbox_test.go (76%)
create mode 100644 schedule.go
rename cellschedule_test.go => schedule_test.go (78%)
create mode 100644 shared/shared.go
create mode 100644 thread.go
rename cellthread_test.go => thread_test.go (76%)
rename celltool.go => tool.go (56%)
rename cellconfig_test.go => tool_test.go (86%)
create mode 100644 toolsource.go
rename environmenttoolsource_test.go => toolsource_test.go (57%)
create mode 100644 webhook.go
rename environmentwebhook_test.go => webhook_test.go (79%)
diff --git a/.stats.yml b/.stats.yml
index 281961a..2d71c51 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-6bd8aeaf9c5b9629c1db5e9770e0e735b2c4fc3a4b9f2700b83a7201152088c4.yml
-openapi_spec_hash: b4978a5083d3d075b52101297da89918
-config_hash: 7adda56db5cedcde41b1164cf721c4aa
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-1ca6943fcf7d9c2630357db20c3d1eb4495d4ecab907f4e20f62508175b8ae5c.yml
+openapi_spec_hash: 9c2f51f5495c1b592e96a9e0c9969f46
+config_hash: 5cc3f8a35eb3b078cbd5ebc45d48e6f6
diff --git a/README.md b/README.md
index 883efda..1591844 100644
--- a/README.md
+++ b/README.md
@@ -52,10 +52,10 @@ func main() {
client := cercago.NewClient(
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("CERCA_API_KEY")
)
- thread, err := client.Cells.Threads.New(
+ thread, err := client.Threads.New(
context.TODO(),
- "cell_abc123",
- cercago.CellThreadNewParams{
+ "agent_abc123",
+ cercago.ThreadNewParams{
UserMessage: cercago.F("What's on my calendar today?"),
},
)
@@ -151,7 +151,7 @@ client := cercago.NewClient(
option.WithHeader("X-Some-Header", "custom_header_info"),
)
-client.Cells.New(context.TODO(), ...,
+client.Agents.New(context.TODO(), ...,
// Override the header
option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
// Add an undocumented field to the request body, using sjson syntax
@@ -167,9 +167,34 @@ This library provides some conveniences for working with paginated list endpoint
You can use `.ListAutoPaging()` methods to iterate through items across all pages:
+```go
+iter := client.Agents.ListAutoPaging(context.TODO(), cercago.AgentListParams{})
+// Automatically fetches more pages as needed.
+for iter.Next() {
+ agentSummary := iter.Current()
+ fmt.Printf("%+v\n", agentSummary)
+}
+if err := iter.Err(); err != nil {
+ panic(err.Error())
+}
+```
+
Or you can use simple `.List()` methods to fetch a single page and receive a standard response object
with additional helper methods like `.GetNextPage()`, e.g.:
+```go
+page, err := client.Agents.List(context.TODO(), cercago.AgentListParams{})
+for page != nil {
+ for _, agent := range page.Agents {
+ fmt.Printf("%+v\n", agent)
+ }
+ page, err = page.GetNextPage()
+}
+if err != nil {
+ panic(err.Error())
+}
+```
+
### Errors
When the API returns a non-success status code, we return an error with type
@@ -180,7 +205,7 @@ When the API returns a non-success status code, we return an error with type
To handle errors, we recommend that you use the `errors.As` pattern:
```go
-_, err := client.Cells.New(context.TODO(), cercago.CellNewParams{
+_, err := client.Agents.New(context.TODO(), cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if err != nil {
@@ -189,7 +214,7 @@ if err != nil {
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
}
- panic(err.Error()) // GET "/cells": 400 Bad Request { ... }
+ panic(err.Error()) // GET "/agents": 400 Bad Request { ... }
}
```
@@ -207,9 +232,9 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
-client.Cells.New(
+client.Agents.New(
ctx,
- cercago.CellNewParams{
+ cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
},
// This sets the per-retry timeout
@@ -245,9 +270,9 @@ client := cercago.NewClient(
)
// Override per-request:
-client.Cells.New(
+client.Agents.New(
context.TODO(),
- cercago.CellNewParams{
+ cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
},
option.WithMaxRetries(5),
@@ -262,9 +287,9 @@ you need to examine response headers, status codes, or other details.
```go
// Create a variable to store the HTTP response
var response *http.Response
-cell, err := client.Cells.New(
+agent, err := client.Agents.New(
context.TODO(),
- cercago.CellNewParams{
+ cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
},
option.WithResponseInto(&response),
@@ -272,7 +297,7 @@ cell, err := client.Cells.New(
if err != nil {
// handle error
}
-fmt.Printf("%+v\n", cell)
+fmt.Printf("%+v\n", agent)
fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
diff --git a/agent.go b/agent.go
new file mode 100644
index 0000000..d8063c9
--- /dev/null
+++ b/agent.go
@@ -0,0 +1,610 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "reflect"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+ "github.com/matrices/cerca-go/shared"
+ "github.com/tidwall/gjson"
+)
+
+// AgentService contains methods and other services that help with interacting with
+// the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewAgentService] method instead.
+type AgentService struct {
+ Options []option.RequestOption
+}
+
+// NewAgentService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewAgentService(opts ...option.RequestOption) (r *AgentService) {
+ r = &AgentService{}
+ r.Options = opts
+ return
+}
+
+func (r *AgentService) New(ctx context.Context, body AgentNewParams, opts ...option.RequestOption) (res *Agent, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "agents"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *AgentService) Get(ctx context.Context, agentID string, opts ...option.RequestOption) (res *Agent, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *AgentService) Update(ctx context.Context, agentID string, body AgentUpdateParams, opts ...option.RequestOption) (res *Agent, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *AgentService) List(ctx context.Context, query AgentListParams, opts ...option.RequestOption) (res *pagination.AgentsCursorPage[AgentSummary], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ path := "agents"
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *AgentService) ListAutoPaging(ctx context.Context, query AgentListParams, opts ...option.RequestOption) *pagination.AgentsCursorPageAutoPager[AgentSummary] {
+ return pagination.NewAgentsCursorPageAutoPager(r.List(ctx, query, opts...))
+}
+
+func (r *AgentService) Delete(ctx context.Context, agentID string, opts ...option.RequestOption) (res *AgentDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *AgentService) GetConfig(ctx context.Context, agentID string, opts ...option.RequestOption) (res *EffectiveConfiguration, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/config", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *AgentService) UpdateMetadata(ctx context.Context, agentID string, body AgentUpdateMetadataParams, opts ...option.RequestOption) (res *Agent, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/metadata", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
+ return res, err
+}
+
+type Agent struct {
+ ID string `json:"id" api:"required"`
+ Configuration Configuration `json:"configuration" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ ExecutionPrincipal ExecutionPrincipal `json:"executionPrincipal" api:"required,nullable"`
+ FleetID string `json:"fleetId" api:"required"`
+ // Arbitrary string metadata stored on an agent. Runtime enforces maximum key and
+ // value sizes.
+ Metadata Metadata `json:"metadata" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ UserID string `json:"userId" api:"required"`
+ Effective EffectiveConfiguration `json:"effective"`
+ JSON agentJSON `json:"-"`
+}
+
+// agentJSON contains the JSON metadata for the struct [Agent]
+type agentJSON struct {
+ ID apijson.Field
+ Configuration apijson.Field
+ CreatedAt apijson.Field
+ ExecutionPrincipal apijson.Field
+ FleetID apijson.Field
+ Metadata apijson.Field
+ OrgID apijson.Field
+ UpdatedAt apijson.Field
+ UserID apijson.Field
+ Effective apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Agent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r agentJSON) RawJSON() string {
+ return r.raw
+}
+
+type AgentSummary struct {
+ ID string `json:"id" api:"required"`
+ ActiveThreadCount float64 `json:"activeThreadCount" api:"required"`
+ AwaitingThreadCount float64 `json:"awaitingThreadCount" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ DefaultModel string `json:"defaultModel" api:"required,nullable"`
+ FleetID string `json:"fleetId" api:"required"`
+ // Arbitrary string metadata stored on an agent. Runtime enforces maximum key and
+ // value sizes.
+ Metadata Metadata `json:"metadata" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ UserID string `json:"userId" api:"required"`
+ JSON agentSummaryJSON `json:"-"`
+}
+
+// agentSummaryJSON contains the JSON metadata for the struct [AgentSummary]
+type agentSummaryJSON struct {
+ ID apijson.Field
+ ActiveThreadCount apijson.Field
+ AwaitingThreadCount apijson.Field
+ CreatedAt apijson.Field
+ DefaultModel apijson.Field
+ FleetID apijson.Field
+ Metadata apijson.Field
+ OrgID apijson.Field
+ UpdatedAt apijson.Field
+ UserID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *AgentSummary) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r agentSummaryJSON) RawJSON() string {
+ return r.raw
+}
+
+type ApprovalPolicy struct {
+ TimeoutMs float64 `json:"timeoutMs"`
+ Tools map[string]shared.ApprovalMode `json:"tools"`
+ JSON approvalPolicyJSON `json:"-"`
+}
+
+// approvalPolicyJSON contains the JSON metadata for the struct [ApprovalPolicy]
+type approvalPolicyJSON struct {
+ TimeoutMs apijson.Field
+ Tools apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ApprovalPolicy) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r approvalPolicyJSON) RawJSON() string {
+ return r.raw
+}
+
+type ApprovalPolicyParam struct {
+ TimeoutMs param.Field[float64] `json:"timeoutMs"`
+ Tools param.Field[map[string]shared.ApprovalMode] `json:"tools"`
+}
+
+func (r ApprovalPolicyParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type Configuration struct {
+ Approvals ApprovalPolicy `json:"approvals"`
+ DefaultModel string `json:"defaultModel"`
+ Instructions string `json:"instructions"`
+ Tools []shared.ToolSpec `json:"tools"`
+ JSON configurationJSON `json:"-"`
+}
+
+// configurationJSON contains the JSON metadata for the struct [Configuration]
+type configurationJSON struct {
+ Approvals apijson.Field
+ DefaultModel apijson.Field
+ Instructions apijson.Field
+ Tools apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Configuration) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r configurationJSON) RawJSON() string {
+ return r.raw
+}
+
+type ConfigurationParam struct {
+ Approvals param.Field[ApprovalPolicyParam] `json:"approvals"`
+ DefaultModel param.Field[string] `json:"defaultModel"`
+ Instructions param.Field[string] `json:"instructions"`
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+}
+
+func (r ConfigurationParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type ConfigurationFieldName string
+
+const (
+ ConfigurationFieldNameDefaultModel ConfigurationFieldName = "defaultModel"
+ ConfigurationFieldNameInstructions ConfigurationFieldName = "instructions"
+ ConfigurationFieldNameTools ConfigurationFieldName = "tools"
+ ConfigurationFieldNameApprovals ConfigurationFieldName = "approvals"
+)
+
+func (r ConfigurationFieldName) IsKnown() bool {
+ switch r {
+ case ConfigurationFieldNameDefaultModel, ConfigurationFieldNameInstructions, ConfigurationFieldNameTools, ConfigurationFieldNameApprovals:
+ return true
+ }
+ return false
+}
+
+type EffectiveConfiguration struct {
+ Approvals EffectiveConfigurationApprovals `json:"approvals" api:"required"`
+ ApprovalsWritableByAgent bool `json:"approvalsWritableByAgent" api:"required"`
+ DefaultModel string `json:"defaultModel" api:"required"`
+ LockedByFleet []ConfigurationFieldName `json:"lockedByFleet" api:"required"`
+ ResolvedFromFleet []ConfigurationFieldName `json:"resolvedFromFleet" api:"required"`
+ Tools []shared.ToolName `json:"tools" api:"required"`
+ Instructions string `json:"instructions"`
+ JSON effectiveConfigurationJSON `json:"-"`
+}
+
+// effectiveConfigurationJSON contains the JSON metadata for the struct
+// [EffectiveConfiguration]
+type effectiveConfigurationJSON struct {
+ Approvals apijson.Field
+ ApprovalsWritableByAgent apijson.Field
+ DefaultModel apijson.Field
+ LockedByFleet apijson.Field
+ ResolvedFromFleet apijson.Field
+ Tools apijson.Field
+ Instructions apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *EffectiveConfiguration) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r effectiveConfigurationJSON) RawJSON() string {
+ return r.raw
+}
+
+type EffectiveConfigurationApprovals struct {
+ TimeoutMs float64 `json:"timeoutMs" api:"required"`
+ Tools map[string]shared.ApprovalMode `json:"tools" api:"required"`
+ JSON effectiveConfigurationApprovalsJSON `json:"-"`
+}
+
+// effectiveConfigurationApprovalsJSON contains the JSON metadata for the struct
+// [EffectiveConfigurationApprovals]
+type effectiveConfigurationApprovalsJSON struct {
+ TimeoutMs apijson.Field
+ Tools apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *EffectiveConfigurationApprovals) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r effectiveConfigurationApprovalsJSON) RawJSON() string {
+ return r.raw
+}
+
+type ExecutionPrincipal struct {
+ Kind ExecutionPrincipalKind `json:"kind" api:"required"`
+ FleetID string `json:"fleetId" api:"nullable"`
+ KeyID string `json:"keyId"`
+ UserID string `json:"userId"`
+ JSON executionPrincipalJSON `json:"-"`
+ union ExecutionPrincipalUnion
+}
+
+// executionPrincipalJSON contains the JSON metadata for the struct
+// [ExecutionPrincipal]
+type executionPrincipalJSON struct {
+ Kind apijson.Field
+ FleetID apijson.Field
+ KeyID apijson.Field
+ UserID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r executionPrincipalJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *ExecutionPrincipal) UnmarshalJSON(data []byte) (err error) {
+ *r = ExecutionPrincipal{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [ExecutionPrincipalUnion] interface which you can cast to the
+// specific types for more type safety.
+//
+// Possible runtime types of the union are
+// [ExecutionPrincipalUserExecutionPrincipal],
+// [ExecutionPrincipalAPIKeyExecutionPrincipal].
+func (r ExecutionPrincipal) AsUnion() ExecutionPrincipalUnion {
+ return r.union
+}
+
+// Union satisfied by [ExecutionPrincipalUserExecutionPrincipal] or
+// [ExecutionPrincipalAPIKeyExecutionPrincipal].
+type ExecutionPrincipalUnion interface {
+ implementsExecutionPrincipal()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ExecutionPrincipalUnion)(nil)).Elem(),
+ "",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ExecutionPrincipalUserExecutionPrincipal{}),
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ExecutionPrincipalAPIKeyExecutionPrincipal{}),
+ },
+ )
+}
+
+type ExecutionPrincipalUserExecutionPrincipal struct {
+ Kind ExecutionPrincipalUserExecutionPrincipalKind `json:"kind" api:"required"`
+ UserID string `json:"userId" api:"required"`
+ JSON executionPrincipalUserExecutionPrincipalJSON `json:"-"`
+}
+
+// executionPrincipalUserExecutionPrincipalJSON contains the JSON metadata for the
+// struct [ExecutionPrincipalUserExecutionPrincipal]
+type executionPrincipalUserExecutionPrincipalJSON struct {
+ Kind apijson.Field
+ UserID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ExecutionPrincipalUserExecutionPrincipal) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r executionPrincipalUserExecutionPrincipalJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ExecutionPrincipalUserExecutionPrincipal) implementsExecutionPrincipal() {}
+
+type ExecutionPrincipalUserExecutionPrincipalKind string
+
+const (
+ ExecutionPrincipalUserExecutionPrincipalKindUser ExecutionPrincipalUserExecutionPrincipalKind = "user"
+)
+
+func (r ExecutionPrincipalUserExecutionPrincipalKind) IsKnown() bool {
+ switch r {
+ case ExecutionPrincipalUserExecutionPrincipalKindUser:
+ return true
+ }
+ return false
+}
+
+type ExecutionPrincipalAPIKeyExecutionPrincipal struct {
+ FleetID string `json:"fleetId" api:"required,nullable"`
+ KeyID string `json:"keyId" api:"required"`
+ Kind ExecutionPrincipalAPIKeyExecutionPrincipalKind `json:"kind" api:"required"`
+ JSON executionPrincipalAPIKeyExecutionPrincipalJSON `json:"-"`
+}
+
+// executionPrincipalAPIKeyExecutionPrincipalJSON contains the JSON metadata for
+// the struct [ExecutionPrincipalAPIKeyExecutionPrincipal]
+type executionPrincipalAPIKeyExecutionPrincipalJSON struct {
+ FleetID apijson.Field
+ KeyID apijson.Field
+ Kind apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ExecutionPrincipalAPIKeyExecutionPrincipal) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r executionPrincipalAPIKeyExecutionPrincipalJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ExecutionPrincipalAPIKeyExecutionPrincipal) implementsExecutionPrincipal() {}
+
+type ExecutionPrincipalAPIKeyExecutionPrincipalKind string
+
+const (
+ ExecutionPrincipalAPIKeyExecutionPrincipalKindAPIKey ExecutionPrincipalAPIKeyExecutionPrincipalKind = "apiKey"
+)
+
+func (r ExecutionPrincipalAPIKeyExecutionPrincipalKind) IsKnown() bool {
+ switch r {
+ case ExecutionPrincipalAPIKeyExecutionPrincipalKindAPIKey:
+ return true
+ }
+ return false
+}
+
+type ExecutionPrincipalKind string
+
+const (
+ ExecutionPrincipalKindUser ExecutionPrincipalKind = "user"
+ ExecutionPrincipalKindAPIKey ExecutionPrincipalKind = "apiKey"
+)
+
+func (r ExecutionPrincipalKind) IsKnown() bool {
+ switch r {
+ case ExecutionPrincipalKindUser, ExecutionPrincipalKindAPIKey:
+ return true
+ }
+ return false
+}
+
+type Metadata map[string]string
+
+type MetadataParam map[string]string
+
+type AgentDeleteResponse struct {
+ Success AgentDeleteResponseSuccess `json:"success" api:"required"`
+ JSON agentDeleteResponseJSON `json:"-"`
+}
+
+// agentDeleteResponseJSON contains the JSON metadata for the struct
+// [AgentDeleteResponse]
+type agentDeleteResponseJSON struct {
+ Success apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *AgentDeleteResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r agentDeleteResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type AgentDeleteResponseSuccess bool
+
+const (
+ AgentDeleteResponseSuccessTrue AgentDeleteResponseSuccess = true
+)
+
+func (r AgentDeleteResponseSuccess) IsKnown() bool {
+ switch r {
+ case AgentDeleteResponseSuccessTrue:
+ return true
+ }
+ return false
+}
+
+type AgentNewParams struct {
+ UserID param.Field[string] `json:"userId" api:"required"`
+ Configuration param.Field[ConfigurationParam] `json:"configuration"`
+ FleetID param.Field[string] `json:"fleetId"`
+ // Arbitrary string metadata stored on an agent. Runtime enforces maximum key and
+ // value sizes.
+ Metadata param.Field[MetadataParam] `json:"metadata"`
+}
+
+func (r AgentNewParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type AgentUpdateParams struct {
+ Configuration param.Field[ConfigurationParam] `json:"configuration" api:"required"`
+}
+
+func (r AgentUpdateParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type AgentListParams struct {
+ // When set to true, lists only agents with active or awaiting threads.
+ Active param.Field[AgentListParamsActive] `query:"active"`
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Fleet to list agents from. Defaults to the API key's default fleet when omitted.
+ FleetID param.Field[string] `query:"fleetId"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [AgentListParams]'s query parameters as `url.Values`.
+func (r AgentListParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When set to true, lists only agents with active or awaiting threads.
+type AgentListParamsActive string
+
+const (
+ AgentListParamsActiveTrue AgentListParamsActive = "true"
+ AgentListParamsActiveFalse AgentListParamsActive = "false"
+)
+
+func (r AgentListParamsActive) IsKnown() bool {
+ switch r {
+ case AgentListParamsActiveTrue, AgentListParamsActiveFalse:
+ return true
+ }
+ return false
+}
+
+type AgentUpdateMetadataParams struct {
+ // Arbitrary string metadata stored on an agent. Runtime enforces maximum key and
+ // value sizes.
+ Metadata param.Field[MetadataParam] `json:"metadata" api:"required"`
+}
+
+func (r AgentUpdateMetadataParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/agent_test.go b/agent_test.go
new file mode 100644
index 0000000..53b3b6f
--- /dev/null
+++ b/agent_test.go
@@ -0,0 +1,215 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago_test
+
+import (
+ "context"
+ "errors"
+ "os"
+ "testing"
+
+ "github.com/matrices/cerca-go"
+ "github.com/matrices/cerca-go/internal/testutil"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/shared"
+)
+
+func TestAgentNewWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Agents.New(context.TODO(), cercago.AgentNewParams{
+ UserID: cercago.F("userId"),
+ Configuration: cercago.F(cercago.ConfigurationParam{
+ Approvals: cercago.F(cercago.ApprovalPolicyParam{
+ TimeoutMs: cercago.F(0.000000),
+ Tools: cercago.F(map[string]shared.ApprovalMode{
+ "foo": shared.ApprovalModeAlways,
+ }),
+ }),
+ DefaultModel: cercago.F("defaultModel"),
+ Instructions: cercago.F("instructions"),
+ Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
+ }),
+ FleetID: cercago.F("fleetId"),
+ Metadata: cercago.F(cercago.MetadataParam{
+ "project": "alpha",
+ }),
+ })
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAgentGet(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Agents.Get(context.TODO(), "agent_abc123")
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAgentUpdateWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Agents.Update(
+ context.TODO(),
+ "agent_abc123",
+ cercago.AgentUpdateParams{
+ Configuration: cercago.F(cercago.ConfigurationParam{
+ Approvals: cercago.F(cercago.ApprovalPolicyParam{
+ TimeoutMs: cercago.F(0.000000),
+ Tools: cercago.F(map[string]shared.ApprovalMode{
+ "foo": shared.ApprovalModeAlways,
+ }),
+ }),
+ DefaultModel: cercago.F("defaultModel"),
+ Instructions: cercago.F("instructions"),
+ Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
+ }),
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAgentListWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Agents.List(context.TODO(), cercago.AgentListParams{
+ Active: cercago.F(cercago.AgentListParamsActiveTrue),
+ Cursor: cercago.F("cursor_abc123"),
+ FleetID: cercago.F("fleet_abc123"),
+ Limit: cercago.F("20"),
+ })
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAgentDelete(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Agents.Delete(context.TODO(), "agent_abc123")
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAgentGetConfig(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Agents.GetConfig(context.TODO(), "agent_abc123")
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAgentUpdateMetadata(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Agents.UpdateMetadata(
+ context.TODO(),
+ "agent_abc123",
+ cercago.AgentUpdateMetadataParams{
+ Metadata: cercago.F(cercago.MetadataParam{
+ "project": "alpha",
+ }),
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
diff --git a/aliases.go b/aliases.go
index decee40..cd5c747 100644
--- a/aliases.go
+++ b/aliases.go
@@ -4,6 +4,148 @@ package cercago
import (
"github.com/matrices/cerca-go/internal/apierror"
+ "github.com/matrices/cerca-go/shared"
)
type Error = apierror.Error
+
+// This is an alias to an internal type.
+type ApprovalMode = shared.ApprovalMode
+
+// This is an alias to an internal value.
+const ApprovalModeAlways = shared.ApprovalModeAlways
+
+// This is an alias to an internal value.
+const ApprovalModeNever = shared.ApprovalModeNever
+
+// This is an alias to an internal type.
+type ErrorResponse = shared.ErrorResponse
+
+// This is an alias to an internal type.
+type JsonObject = shared.JsonObject
+
+// This is an alias to an internal type.
+type ToolName = shared.ToolName
+
+// This is an alias to an internal value.
+const ToolNameGetTime = shared.ToolNameGetTime
+
+// This is an alias to an internal value.
+const ToolNameSubThread = shared.ToolNameSubThread
+
+// This is an alias to an internal value.
+const ToolNameWait = shared.ToolNameWait
+
+// This is an alias to an internal value.
+const ToolNameToolCall = shared.ToolNameToolCall
+
+// This is an alias to an internal value.
+const ToolNameToolDiscover = shared.ToolNameToolDiscover
+
+// This is an alias to an internal value.
+const ToolNameArtifactRead = shared.ToolNameArtifactRead
+
+// This is an alias to an internal value.
+const ToolNameAgentThreadsList = shared.ToolNameAgentThreadsList
+
+// This is an alias to an internal value.
+const ToolNameAgentThreadsGet = shared.ToolNameAgentThreadsGet
+
+// This is an alias to an internal value.
+const ToolNameAgentApprovalsCancel = shared.ToolNameAgentApprovalsCancel
+
+// This is an alias to an internal value.
+const ToolNameAgentApprovalsGrantThread = shared.ToolNameAgentApprovalsGrantThread
+
+// This is an alias to an internal value.
+const ToolNameAgentApprovalsGrantAgent = shared.ToolNameAgentApprovalsGrantAgent
+
+// This is an alias to an internal value.
+const ToolNameAgentCreate = shared.ToolNameAgentCreate
+
+// This is an alias to an internal value.
+const ToolNameAgentApprovalsUpdate = shared.ToolNameAgentApprovalsUpdate
+
+// This is an alias to an internal value.
+const ToolNameToolConnect = shared.ToolNameToolConnect
+
+// This is an alias to an internal value.
+const ToolNameSandboxExec = shared.ToolNameSandboxExec
+
+// This is an alias to an internal value.
+const ToolNameSandboxRead = shared.ToolNameSandboxRead
+
+// This is an alias to an internal value.
+const ToolNameSandboxWriteFile = shared.ToolNameSandboxWriteFile
+
+// This is an alias to an internal value.
+const ToolNameSandboxReadFile = shared.ToolNameSandboxReadFile
+
+// This is an alias to an internal value.
+const ToolNameSandboxSpawn = shared.ToolNameSandboxSpawn
+
+// This is an alias to an internal value.
+const ToolNameSandboxStdin = shared.ToolNameSandboxStdin
+
+// This is an alias to an internal value.
+const ToolNameSandboxSessionRead = shared.ToolNameSandboxSessionRead
+
+// This is an alias to an internal value.
+const ToolNameSandboxKill = shared.ToolNameSandboxKill
+
+// This is an alias to an internal value.
+const ToolNameSandboxListSessions = shared.ToolNameSandboxListSessions
+
+// This is an alias to an internal value.
+const ToolNameSandboxSyncArtifact = shared.ToolNameSandboxSyncArtifact
+
+// This is an alias to an internal value.
+const ToolNameMemoryRead = shared.ToolNameMemoryRead
+
+// This is an alias to an internal value.
+const ToolNameMemoryList = shared.ToolNameMemoryList
+
+// This is an alias to an internal value.
+const ToolNameMemorySearch = shared.ToolNameMemorySearch
+
+// This is an alias to an internal value.
+const ToolNameMemoryWrite = shared.ToolNameMemoryWrite
+
+// This is an alias to an internal value.
+const ToolNameMemoryDelete = shared.ToolNameMemoryDelete
+
+// This is an alias to an internal value.
+const ToolNameDBQuery = shared.ToolNameDBQuery
+
+// This is an alias to an internal value.
+const ToolNameWebSearch = shared.ToolNameWebSearch
+
+// This is an alias to an internal value.
+const ToolNameWebFetch = shared.ToolNameWebFetch
+
+// This is an alias to an internal value.
+const ToolNameAgentScheduleList = shared.ToolNameAgentScheduleList
+
+// This is an alias to an internal value.
+const ToolNameAgentScheduleCreate = shared.ToolNameAgentScheduleCreate
+
+// This is an alias to an internal value.
+const ToolNameAgentScheduleUpdate = shared.ToolNameAgentScheduleUpdate
+
+// This is an alias to an internal value.
+const ToolNameAgentScheduleDelete = shared.ToolNameAgentScheduleDelete
+
+// This is an alias to an internal value.
+const ToolNameAgentScheduleTrigger = shared.ToolNameAgentScheduleTrigger
+
+// Configurable runtime tool name, configurable namespace wildcard such as
+// sandbox._, or external namespace wildcard such as google._.
+//
+// This is an alias to an internal type.
+type ToolSpec = shared.ToolSpec
+
+// Configurable runtime tool name, configurable namespace wildcard such as
+// sandbox._, or external namespace wildcard such as google._.
+//
+// This is an alias to an internal type.
+type ToolSpecParam = shared.ToolSpecParam
diff --git a/api.md b/api.md
index dfc0d3c..0d190c0 100644
--- a/api.md
+++ b/api.md
@@ -1,14 +1,28 @@
+# Shared Params Types
+
+- shared.ApprovalMode
+- shared.ToolName
+- shared.ToolSpecParam
+
+# Shared Response Types
+
+- shared.ApprovalMode
+- shared.ErrorResponse
+- shared.JsonObject
+- shared.ToolName
+- shared.ToolSpec
+
# Auth
Response Types:
- cercago.AuthContextResponse
-- cercago.AuthListEnvironmentsResponse
+- cercago.AuthFleetsResponse
Methods:
- client.Auth.Context(ctx context.Context) (\*cercago.AuthContextResponse, error)
-- client.Auth.ListEnvironments(ctx context.Context, query cercago.AuthListEnvironmentsParams) (\*cercago.AuthListEnvironmentsResponse, error)
+- client.Auth.ListFleets(ctx context.Context, query cercago.AuthListFleetsParams) (\*pagination.FleetsCursorPage[cercago.Fleet], error)
# OAuth
@@ -27,22 +41,21 @@ Response Types:
- cercago.Connection
- cercago.CredentialProvider
- cercago.CredentialType
-- cercago.CredentialListResponse
- cercago.CredentialDeleteResponse
Methods:
-- client.Credentials.List(ctx context.Context, scope string, query cercago.CredentialListParams) (\*cercago.CredentialListResponse, error)
+- client.Credentials.List(ctx context.Context, scope string, query cercago.CredentialListParams) (\*pagination.ConnectionsCursorPage[cercago.Connection], error)
- client.Credentials.Delete(ctx context.Context, scope string, connectionID string) (\*cercago.CredentialDeleteResponse, error)
- client.Credentials.NewAPIKey(ctx context.Context, scope string, body cercago.CredentialNewAPIKeyParams) (\*cercago.Connection, error)
-# Environments
+# Fleets
Response Types:
-- cercago.Environment
+- cercago.Fleet
-## ToolSources
+# ToolSources
Params Types:
@@ -62,17 +75,18 @@ Response Types:
- cercago.ToolApprovalMode
- cercago.ToolSource
- cercago.ToolSourceAuth
-- cercago.EnvironmentToolSourceListResponse
+- cercago.ToolSourceListForAgentResponse
Methods:
-- client.Environments.ToolSources.New(ctx context.Context, environmentID string, body cercago.EnvironmentToolSourceNewParams) (\*cercago.ToolSource, error)
-- client.Environments.ToolSources.Get(ctx context.Context, environmentID string, sourceID string) (\*cercago.ToolSource, error)
-- client.Environments.ToolSources.Update(ctx context.Context, environmentID string, sourceID string, body cercago.EnvironmentToolSourceUpdateParams) (\*cercago.ToolSource, error)
-- client.Environments.ToolSources.List(ctx context.Context, environmentID string, query cercago.EnvironmentToolSourceListParams) (\*cercago.EnvironmentToolSourceListResponse, error)
-- client.Environments.ToolSources.Delete(ctx context.Context, environmentID string, sourceID string) error
+- client.ToolSources.New(ctx context.Context, fleetID string, body cercago.ToolSourceNewParams) (\*cercago.ToolSource, error)
+- client.ToolSources.Get(ctx context.Context, fleetID string, sourceID string) (\*cercago.ToolSource, error)
+- client.ToolSources.Update(ctx context.Context, fleetID string, sourceID string, body cercago.ToolSourceUpdateParams) (\*cercago.ToolSource, error)
+- client.ToolSources.List(ctx context.Context, fleetID string, query cercago.ToolSourceListParams) (\*pagination.SourcesCursorPage[cercago.ToolSource], error)
+- client.ToolSources.Delete(ctx context.Context, fleetID string, sourceID string) error
+- client.ToolSources.ListForAgent(ctx context.Context, agentID string) (\*cercago.ToolSourceListForAgentResponse, error)
-## Webhooks
+# Webhooks
Params Types:
@@ -83,295 +97,212 @@ Response Types:
- cercago.WebhookEventType
- cercago.WebhookSubscription
- cercago.WebhookSubscriptionCreated
-- cercago.EnvironmentWebhookListResponse
-- cercago.EnvironmentWebhookTestResponse
+- cercago.WebhookTestResponse
Methods:
-- client.Environments.Webhooks.New(ctx context.Context, environmentID string, body cercago.EnvironmentWebhookNewParams) (\*cercago.WebhookSubscriptionCreated, error)
-- client.Environments.Webhooks.Get(ctx context.Context, environmentID string, webhookID string) (\*cercago.WebhookSubscription, error)
-- client.Environments.Webhooks.Update(ctx context.Context, environmentID string, webhookID string, body cercago.EnvironmentWebhookUpdateParams) (\*cercago.WebhookSubscription, error)
-- client.Environments.Webhooks.List(ctx context.Context, environmentID string, query cercago.EnvironmentWebhookListParams) (\*cercago.EnvironmentWebhookListResponse, error)
-- client.Environments.Webhooks.Delete(ctx context.Context, environmentID string, webhookID string) error
-- client.Environments.Webhooks.Rotate(ctx context.Context, environmentID string, webhookID string) (\*cercago.WebhookSubscriptionCreated, error)
-- client.Environments.Webhooks.Test(ctx context.Context, environmentID string, webhookID string) (\*cercago.EnvironmentWebhookTestResponse, error)
+- client.Webhooks.New(ctx context.Context, fleetID string, body cercago.WebhookNewParams) (\*cercago.WebhookSubscriptionCreated, error)
+- client.Webhooks.Get(ctx context.Context, fleetID string, webhookID string) (\*cercago.WebhookSubscription, error)
+- client.Webhooks.Update(ctx context.Context, fleetID string, webhookID string, body cercago.WebhookUpdateParams) (\*cercago.WebhookSubscription, error)
+- client.Webhooks.List(ctx context.Context, fleetID string, query cercago.WebhookListParams) (\*pagination.SubscriptionsCursorPage[cercago.WebhookSubscription], error)
+- client.Webhooks.Delete(ctx context.Context, fleetID string, webhookID string) error
+- client.Webhooks.Rotate(ctx context.Context, fleetID string, webhookID string) (\*cercago.WebhookSubscriptionCreated, error)
+- client.Webhooks.Test(ctx context.Context, fleetID string, webhookID string) (\*cercago.WebhookTestResponse, error)
-## Events
+# Events
Response Types:
- cercago.RuntimeWebhookEvent
- cercago.RuntimeWebhookEventType
- cercago.SubscriptionEvent
-- cercago.EnvironmentEventListResponse
-- cercago.EnvironmentEventSubscribeResponse
Methods:
-- client.Environments.Events.List(ctx context.Context, envID string, query cercago.EnvironmentEventListParams) (\*cercago.EnvironmentEventListResponse, error)
-- client.Environments.Events.Subscribe(ctx context.Context, envID string) (\*cercago.EnvironmentEventSubscribeResponse, error)
+- client.Events.ListForAgent(ctx context.Context, agentID string, query cercago.EventListForAgentParams) (\*pagination.EventsCursorPage[cercago.SubscriptionEvent], error)
+- client.Events.ListForFleet(ctx context.Context, fleetID string, query cercago.EventListForFleetParams) (\*pagination.EventsCursorPage[cercago.SubscriptionEvent], error)
+- client.Events.ListForThread(ctx context.Context, agentID string, threadID string, query cercago.EventListForThreadParams) (\*pagination.EventsCursorPage[cercago.SubscriptionEvent], error)
+- client.Events.SubscribeAgent(ctx context.Context, agentID string) (\*shared.ErrorResponse, error)
+- client.Events.SubscribeFleet(ctx context.Context, fleetID string) (\*shared.ErrorResponse, error)
+- client.Events.SubscribeThread(ctx context.Context, agentID string, threadID string) (\*shared.ErrorResponse, error)
-# Cells
+# Agents
Params Types:
-- cercago.CellConfigurationParam
-- cercago.CellMetadataParam
-- cercago.RuntimeToolApprovalOverrideMode
+- cercago.ApprovalPolicyParam
+- cercago.ConfigurationParam
+- cercago.MetadataParam
Response Types:
-- cercago.Cell
-- cercago.CellConfiguration
-- cercago.CellMetadata
-- cercago.CellSummary
+- cercago.Agent
+- cercago.AgentSummary
+- cercago.ApprovalPolicy
+- cercago.Configuration
+- cercago.ConfigurationFieldName
+- cercago.EffectiveConfiguration
- cercago.ExecutionPrincipal
-- cercago.RuntimeToolApprovalOverrideMode
-- cercago.CellListResponse
-- cercago.CellDeleteResponse
+- cercago.Metadata
+- cercago.AgentDeleteResponse
Methods:
-- client.Cells.New(ctx context.Context, body cercago.CellNewParams) (\*cercago.Cell, error)
-- client.Cells.Get(ctx context.Context, cellID string) (\*cercago.Cell, error)
-- client.Cells.Update(ctx context.Context, cellID string, body cercago.CellUpdateParams) (\*cercago.Cell, error)
-- client.Cells.List(ctx context.Context, query cercago.CellListParams) (\*cercago.CellListResponse, error)
-- client.Cells.Delete(ctx context.Context, cellID string) (\*cercago.CellDeleteResponse, error)
-
-## Config
-
-Methods:
-
-- client.Cells.Config.Get(ctx context.Context, cellID string) (\*cercago.CellConfiguration, error)
-
-## Metadata
-
-Methods:
+- client.Agents.New(ctx context.Context, body cercago.AgentNewParams) (\*cercago.Agent, error)
+- client.Agents.Get(ctx context.Context, agentID string) (\*cercago.Agent, error)
+- client.Agents.Update(ctx context.Context, agentID string, body cercago.AgentUpdateParams) (\*cercago.Agent, error)
+- client.Agents.List(ctx context.Context, query cercago.AgentListParams) (\*pagination.AgentsCursorPage[cercago.AgentSummary], error)
+- client.Agents.Delete(ctx context.Context, agentID string) (\*cercago.AgentDeleteResponse, error)
+- client.Agents.GetConfig(ctx context.Context, agentID string) (\*cercago.EffectiveConfiguration, error)
+- client.Agents.UpdateMetadata(ctx context.Context, agentID string, body cercago.AgentUpdateMetadataParams) (\*cercago.Agent, error)
-- client.Cells.Metadata.Update(ctx context.Context, cellID string, body cercago.CellMetadataUpdateParams) (\*cercago.Cell, error)
-
-## Tools
+# Threads
Params Types:
-- cercago.RuntimeToolName
-
-Response Types:
-
-- cercago.RuntimeDiscoveredTool
-- cercago.RuntimeSourceWarning
-- cercago.RuntimeToolDescriptor
-- cercago.RuntimeToolName
-- cercago.CellToolListResponse
-
-Methods:
-
-- client.Cells.Tools.List(ctx context.Context, cellID string) (\*cercago.CellToolListResponse, error)
-
-## ToolSources
-
-Response Types:
-
-- cercago.CellToolSourceListResponse
-
-Methods:
-
-- client.Cells.ToolSources.List(ctx context.Context, cellID string) (\*cercago.CellToolSourceListResponse, error)
-
-## Context
-
-Response Types:
-
-- cercago.ContextEntry
-- cercago.ContextEntrySummary
-- cercago.ContextSearchResult
-- cercago.CellContextListResponse
-- cercago.CellContextSearchResponse
-
-Methods:
-
-- client.Cells.Context.List(ctx context.Context, cellID string, query cercago.CellContextListParams) (\*cercago.CellContextListResponse, error)
-- client.Cells.Context.Search(ctx context.Context, cellID string, query cercago.CellContextSearchParams) (\*cercago.CellContextSearchResponse, error)
-
-### Entries
-
-Response Types:
-
-- cercago.CellContextEntryDeleteResponse
-
-Methods:
-
-- client.Cells.Context.Entries.Get(ctx context.Context, cellID string, query cercago.CellContextEntryGetParams) (\*cercago.ContextEntry, error)
-- client.Cells.Context.Entries.Delete(ctx context.Context, cellID string, body cercago.CellContextEntryDeleteParams) (\*cercago.CellContextEntryDeleteResponse, error)
-- client.Cells.Context.Entries.Put(ctx context.Context, cellID string, body cercago.CellContextEntryPutParams) (\*cercago.ContextEntry, error)
-
-## Connections
-
-Params Types:
-
-- cercago.ToolConnectionMetadataParam
-
-Response Types:
-
-- cercago.AttachedConnection
-- cercago.ToolConnectionMetadata
-- cercago.CellConnectionListResponse
-- cercago.CellConnectionDetachResponse
-
-Methods:
-
-- client.Cells.Connections.List(ctx context.Context, cellID string) (\*cercago.CellConnectionListResponse, error)
-- client.Cells.Connections.Attach(ctx context.Context, cellID string, body cercago.CellConnectionAttachParams) (\*cercago.AttachedConnection, error)
-- client.Cells.Connections.Detach(ctx context.Context, cellID string, connectionID string) (\*cercago.CellConnectionDetachResponse, error)
-
-## Schedules
-
-Response Types:
-
-- cercago.ScheduledThread
-- cercago.CellScheduleListResponse
-- cercago.CellScheduleDeleteResponse
-- cercago.CellScheduleTriggerResponse
-
-Methods:
-
-- client.Cells.Schedules.New(ctx context.Context, cellID string, body cercago.CellScheduleNewParams) (\*cercago.ScheduledThread, error)
-- client.Cells.Schedules.Update(ctx context.Context, cellID string, scheduleID string, body cercago.CellScheduleUpdateParams) (\*cercago.ScheduledThread, error)
-- client.Cells.Schedules.List(ctx context.Context, cellID string) (\*cercago.CellScheduleListResponse, error)
-- client.Cells.Schedules.Delete(ctx context.Context, cellID string, scheduleID string) (\*cercago.CellScheduleDeleteResponse, error)
-- client.Cells.Schedules.Trigger(ctx context.Context, cellID string, scheduleID string) (\*cercago.CellScheduleTriggerResponse, error)
-
-## Threads
-
-Params Types:
-
-- cercago.ThreadStatus
+- cercago.Status
Response Types:
+- cercago.CompiledContext
- cercago.ContentBlock
+- cercago.ContextWindow
+- cercago.Message
- cercago.PendingSubThread
+- cercago.Status
- cercago.SteerResult
- cercago.Thread
-- cercago.ThreadCompiledContext
-- cercago.ThreadContextWindow
-- cercago.ThreadMessage
-- cercago.ThreadStatus
- cercago.ThreadSummary
- cercago.TokenUsage
- cercago.Turn
-- cercago.CellThreadListResponse
-
-Methods:
-
-- client.Cells.Threads.New(ctx context.Context, cellID string, body cercago.CellThreadNewParams) (\*cercago.Thread, error)
-- client.Cells.Threads.Get(ctx context.Context, cellID string, threadID string, query cercago.CellThreadGetParams) (\*cercago.Thread, error)
-- client.Cells.Threads.List(ctx context.Context, cellID string, query cercago.CellThreadListParams) (\*cercago.CellThreadListResponse, error)
-- client.Cells.Threads.Cancel(ctx context.Context, cellID string, threadID string) (\*cercago.Thread, error)
-- client.Cells.Threads.Close(ctx context.Context, cellID string, threadID string) (\*cercago.Thread, error)
-- client.Cells.Threads.Compact(ctx context.Context, cellID string, threadID string) (\*cercago.Thread, error)
-- client.Cells.Threads.Steer(ctx context.Context, cellID string, threadID string, body cercago.CellThreadSteerParams) (\*cercago.SteerResult, error)
-- client.Cells.Threads.Turn(ctx context.Context, cellID string, threadID string, body cercago.CellThreadTurnParams) (\*cercago.Turn, error)
-
-### Approvals
Methods:
-- client.Cells.Threads.Approvals.Resolve(ctx context.Context, cellID string, threadID string, approvalID string, body cercago.CellThreadApprovalResolveParams) (\*cercago.ApprovalRequest, error)
+- client.Threads.New(ctx context.Context, agentID string, body cercago.ThreadNewParams) (\*cercago.Thread, error)
+- client.Threads.Get(ctx context.Context, agentID string, threadID string, query cercago.ThreadGetParams) (\*cercago.Thread, error)
+- client.Threads.List(ctx context.Context, agentID string, query cercago.ThreadListParams) (\*pagination.ThreadsCursorPage[cercago.ThreadSummary], error)
+- client.Threads.Cancel(ctx context.Context, agentID string, threadID string) (\*cercago.Thread, error)
+- client.Threads.Close(ctx context.Context, agentID string, threadID string) (\*cercago.Thread, error)
+- client.Threads.Compact(ctx context.Context, agentID string, threadID string) (\*cercago.Thread, error)
+- client.Threads.StartTurn(ctx context.Context, agentID string, threadID string, body cercago.ThreadStartTurnParams) (\*cercago.Turn, error)
+- client.Threads.Steer(ctx context.Context, agentID string, threadID string, body cercago.ThreadSteerParams) (\*cercago.SteerResult, error)
-### ApprovalGrants
+# Context
Response Types:
-- cercago.CellThreadApprovalGrantDeleteResponse
+- cercago.Entry
+- cercago.EntrySummary
+- cercago.SearchResult
+- cercago.ContextDeleteResponse
Methods:
-- client.Cells.Threads.ApprovalGrants.List(ctx context.Context, cellID string, threadID string) (\*[]cercago.ApprovalGrant, error)
-- client.Cells.Threads.ApprovalGrants.Delete(ctx context.Context, cellID string, threadID string, grantID string) (\*cercago.CellThreadApprovalGrantDeleteResponse, error)
+- client.Context.Get(ctx context.Context, agentID string, query cercago.ContextGetParams) (\*cercago.Entry, error)
+- client.Context.List(ctx context.Context, agentID string, query cercago.ContextListParams) (\*pagination.EntriesCursorPage[cercago.EntrySummary], error)
+- client.Context.Delete(ctx context.Context, agentID string, body cercago.ContextDeleteParams) (\*cercago.ContextDeleteResponse, error)
+- client.Context.Search(ctx context.Context, agentID string, query cercago.ContextSearchParams) (\*pagination.ResultsCursorPage[cercago.SearchResult], error)
+- client.Context.Write(ctx context.Context, agentID string, body cercago.ContextWriteParams) (\*cercago.Entry, error)
+
+# Connections
+
+Params Types:
-### Logs
+- cercago.ToolConnectionMetadataParam
Response Types:
-- cercago.ThreadLog
-- cercago.CellThreadLogListResponse
+- cercago.AttachedConnection
+- cercago.ToolConnectionMetadata
+- cercago.ConnectionListResponse
+- cercago.ConnectionDetachResponse
Methods:
-- client.Cells.Threads.Logs.List(ctx context.Context, cellID string, threadID string, query cercago.CellThreadLogListParams) (\*cercago.CellThreadLogListResponse, error)
+- client.Connections.List(ctx context.Context, agentID string) (\*cercago.ConnectionListResponse, error)
+- client.Connections.Attach(ctx context.Context, agentID string, body cercago.ConnectionAttachParams) (\*cercago.AttachedConnection, error)
+- client.Connections.Detach(ctx context.Context, agentID string, connectionID string) (\*cercago.ConnectionDetachResponse, error)
-### Events
+# Schedules
Response Types:
-- cercago.CellThreadEventListResponse
-- cercago.CellThreadEventSubscribeResponse
+- cercago.ScheduledThread
+- cercago.ScheduleListResponse
+- cercago.ScheduleDeleteResponse
+- cercago.ScheduleTriggerResponse
Methods:
-- client.Cells.Threads.Events.List(ctx context.Context, cellID string, threadID string, query cercago.CellThreadEventListParams) (\*cercago.CellThreadEventListResponse, error)
-- client.Cells.Threads.Events.Subscribe(ctx context.Context, cellID string, threadID string) (\*cercago.CellThreadEventSubscribeResponse, error)
+- client.Schedules.New(ctx context.Context, agentID string, body cercago.ScheduleNewParams) (\*cercago.ScheduledThread, error)
+- client.Schedules.Update(ctx context.Context, agentID string, scheduleID string, body cercago.ScheduleUpdateParams) (\*cercago.ScheduledThread, error)
+- client.Schedules.List(ctx context.Context, agentID string) (\*cercago.ScheduleListResponse, error)
+- client.Schedules.Delete(ctx context.Context, agentID string, scheduleID string) (\*cercago.ScheduleDeleteResponse, error)
+- client.Schedules.Trigger(ctx context.Context, agentID string, scheduleID string) (\*cercago.ScheduleTriggerResponse, error)
-## Approvals
+# Approvals
Response Types:
- cercago.ApprovalRequest
-- cercago.CellApprovalListResponse
Methods:
-- client.Cells.Approvals.List(ctx context.Context, cellID string, query cercago.CellApprovalListParams) (\*cercago.CellApprovalListResponse, error)
+- client.Approvals.List(ctx context.Context, agentID string, query cercago.ApprovalListParams) (\*pagination.ApprovalsCursorPage[cercago.ApprovalRequest], error)
+- client.Approvals.Resolve(ctx context.Context, agentID string, threadID string, approvalID string, body cercago.ApprovalResolveParams) (\*cercago.ApprovalRequest, error)
-## ApprovalGrants
+# ApprovalGrants
Response Types:
- cercago.ApprovalGrant
-- cercago.CellApprovalGrantListResponse
-- cercago.CellApprovalGrantDeleteResponse
+- cercago.ApprovalGrantDeleteResponse
+- cercago.ApprovalGrantDeleteForThreadResponse
Methods:
-- client.Cells.ApprovalGrants.List(ctx context.Context, cellID string, query cercago.CellApprovalGrantListParams) (\*cercago.CellApprovalGrantListResponse, error)
-- client.Cells.ApprovalGrants.Delete(ctx context.Context, cellID string, grantID string) (\*cercago.CellApprovalGrantDeleteResponse, error)
+- client.ApprovalGrants.List(ctx context.Context, agentID string, query cercago.ApprovalGrantListParams) (\*pagination.GrantsCursorPage[cercago.ApprovalGrant], error)
+- client.ApprovalGrants.Delete(ctx context.Context, agentID string, grantID string) (\*cercago.ApprovalGrantDeleteResponse, error)
+- client.ApprovalGrants.DeleteForThread(ctx context.Context, agentID string, threadID string, grantID string) (\*cercago.ApprovalGrantDeleteForThreadResponse, error)
+- client.ApprovalGrants.ListForThread(ctx context.Context, agentID string, threadID string) (\*[]cercago.ApprovalGrant, error)
-## Logs
+# Logs
Response Types:
-- cercago.CellLogListResponse
+- cercago.ThreadLog
Methods:
-- client.Cells.Logs.List(ctx context.Context, cellID string, query cercago.CellLogListParams) (\*cercago.CellLogListResponse, error)
+- client.Logs.ListForAgent(ctx context.Context, agentID string, query cercago.LogListForAgentParams) (\*pagination.LogsCursorPage[cercago.ThreadLog], error)
+- client.Logs.ListForThread(ctx context.Context, agentID string, threadID string, query cercago.LogListForThreadParams) (\*pagination.LogsCursorPage[cercago.ThreadLog], error)
-## Sandbox
+# Sandbox
Response Types:
-- cercago.SandboxExecResult
-- cercago.SandboxReadResponse
-- cercago.CellSandboxWriteResponse
+- cercago.ExecResult
+- cercago.ReadResponse
+- cercago.SandboxWriteResponse
Methods:
-- client.Cells.Sandbox.Exec(ctx context.Context, cellID string, body cercago.CellSandboxExecParams) (\*cercago.SandboxExecResult, error)
-- client.Cells.Sandbox.Read(ctx context.Context, cellID string, body cercago.CellSandboxReadParams) (\*cercago.SandboxReadResponse, error)
-- client.Cells.Sandbox.Write(ctx context.Context, cellID string, body cercago.CellSandboxWriteParams) (\*cercago.CellSandboxWriteResponse, error)
+- client.Sandbox.Exec(ctx context.Context, agentID string, body cercago.SandboxExecParams) (\*cercago.ExecResult, error)
+- client.Sandbox.Read(ctx context.Context, agentID string, body cercago.SandboxReadParams) (\*cercago.ReadResponse, error)
+- client.Sandbox.Write(ctx context.Context, agentID string, body cercago.SandboxWriteParams) (\*cercago.SandboxWriteResponse, error)
-## Events
+# Tools
Response Types:
-- cercago.CellEventListResponse
-- cercago.CellEventSubscribeResponse
+- cercago.RuntimeDiscoveredTool
+- cercago.RuntimeSourceWarning
+- cercago.RuntimeToolDescriptor
+- cercago.ToolListForAgentResponse
Methods:
-- client.Cells.Events.List(ctx context.Context, cellID string, query cercago.CellEventListParams) (\*cercago.CellEventListResponse, error)
-- client.Cells.Events.Subscribe(ctx context.Context, cellID string) (\*cercago.CellEventSubscribeResponse, error)
+- client.Tools.ListForAgent(ctx context.Context, agentID string) (\*cercago.ToolListForAgentResponse, error)
# Models
diff --git a/cellapproval.go b/approval.go
similarity index 53%
rename from cellapproval.go
rename to approval.go
index be997e5..e67a4a3 100644
--- a/cellapproval.go
+++ b/approval.go
@@ -15,35 +15,70 @@ import (
"github.com/matrices/cerca-go/internal/param"
"github.com/matrices/cerca-go/internal/requestconfig"
"github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+ "github.com/matrices/cerca-go/shared"
)
-// CellApprovalService contains methods and other services that help with
-// interacting with the cerca API.
+// ApprovalService contains methods and other services that help with interacting
+// with the cerca API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellApprovalService] method instead.
-type CellApprovalService struct {
+// the [NewApprovalService] method instead.
+type ApprovalService struct {
Options []option.RequestOption
}
-// NewCellApprovalService generates a new service that applies the given options to
+// NewApprovalService generates a new service that applies the given options to
// each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
-func NewCellApprovalService(opts ...option.RequestOption) (r *CellApprovalService) {
- r = &CellApprovalService{}
+func NewApprovalService(opts ...option.RequestOption) (r *ApprovalService) {
+ r = &ApprovalService{}
r.Options = opts
return
}
-func (r *CellApprovalService) List(ctx context.Context, cellID string, query CellApprovalListParams, opts ...option.RequestOption) (res *CellApprovalListResponse, err error) {
+func (r *ApprovalService) List(ctx context.Context, agentID string, query ApprovalListParams, opts ...option.RequestOption) (res *pagination.ApprovalsCursorPage[ApprovalRequest], err error) {
+ var raw *http.Response
opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
return nil, err
}
- path := fmt.Sprintf("cells/%s/approvals", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
+ path := fmt.Sprintf("agents/%s/approvals", agentID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ApprovalService) ListAutoPaging(ctx context.Context, agentID string, query ApprovalListParams, opts ...option.RequestOption) *pagination.ApprovalsCursorPageAutoPager[ApprovalRequest] {
+ return pagination.NewApprovalsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
+}
+
+func (r *ApprovalService) Resolve(ctx context.Context, agentID string, threadID string, approvalID string, body ApprovalResolveParams, opts ...option.RequestOption) (res *ApprovalRequest, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ if approvalID == "" {
+ err = errors.New("missing required approvalId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/approvals/%s", agentID, threadID, approvalID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -58,7 +93,7 @@ type ApprovalRequest struct {
TimeoutMs float64 `json:"timeoutMs" api:"required,nullable"`
ToolIndex float64 `json:"toolIndex" api:"required"`
ToolInput string `json:"toolInput" api:"required"`
- ToolName RuntimeToolName `json:"toolName" api:"required"`
+ ToolName shared.ToolName `json:"toolName" api:"required"`
ToolUseID string `json:"toolUseId" api:"required"`
TurnID string `json:"turnId" api:"required"`
ToolSourceID string `json:"toolSourceId"`
@@ -113,32 +148,7 @@ func (r ApprovalRequestStatus) IsKnown() bool {
return false
}
-type CellApprovalListResponse struct {
- Approvals []ApprovalRequest `json:"approvals" api:"required"`
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON cellApprovalListResponseJSON `json:"-"`
-}
-
-// cellApprovalListResponseJSON contains the JSON metadata for the struct
-// [CellApprovalListResponse]
-type cellApprovalListResponseJSON struct {
- Approvals apijson.Field
- Cursor apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellApprovalListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellApprovalListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellApprovalListParams struct {
+type ApprovalListParams struct {
// Opaque pagination cursor returned by a previous request.
Cursor param.Field[string] `query:"cursor"`
// Maximum number of items to return. Defaults to 20 and preserves parseInt
@@ -148,10 +158,50 @@ type CellApprovalListParams struct {
ThreadID param.Field[string] `query:"threadId"`
}
-// URLQuery serializes [CellApprovalListParams]'s query parameters as `url.Values`.
-func (r CellApprovalListParams) URLQuery() (v url.Values) {
+// URLQuery serializes [ApprovalListParams]'s query parameters as `url.Values`.
+func (r ApprovalListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
+
+type ApprovalResolveParams struct {
+ Decision param.Field[ApprovalResolveParamsDecision] `json:"decision" api:"required"`
+ Grant param.Field[ApprovalResolveParamsGrant] `json:"grant"`
+}
+
+func (r ApprovalResolveParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type ApprovalResolveParamsDecision string
+
+const (
+ ApprovalResolveParamsDecisionApprove ApprovalResolveParamsDecision = "approve"
+ ApprovalResolveParamsDecisionDeny ApprovalResolveParamsDecision = "deny"
+ ApprovalResolveParamsDecisionCancel ApprovalResolveParamsDecision = "cancel"
+)
+
+func (r ApprovalResolveParamsDecision) IsKnown() bool {
+ switch r {
+ case ApprovalResolveParamsDecisionApprove, ApprovalResolveParamsDecisionDeny, ApprovalResolveParamsDecisionCancel:
+ return true
+ }
+ return false
+}
+
+type ApprovalResolveParamsGrant string
+
+const (
+ ApprovalResolveParamsGrantThread ApprovalResolveParamsGrant = "thread"
+ ApprovalResolveParamsGrantAgent ApprovalResolveParamsGrant = "agent"
+)
+
+func (r ApprovalResolveParamsGrant) IsKnown() bool {
+ switch r {
+ case ApprovalResolveParamsGrantThread, ApprovalResolveParamsGrantAgent:
+ return true
+ }
+ return false
+}
diff --git a/cellthreadevent_test.go b/approval_test.go
similarity index 69%
rename from cellthreadevent_test.go
rename to approval_test.go
index 4aab4fd..ba1162f 100644
--- a/cellthreadevent_test.go
+++ b/approval_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellThreadEventListWithOptionalParams(t *testing.T) {
+func TestApprovalListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,15 +25,13 @@ func TestCellThreadEventListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Events.List(
+ _, err := client.Approvals.List(
context.TODO(),
- "cell_abc123",
- "thread_abc123",
- cercago.CellThreadEventListParams{
- Cursor: cercago.F("cursor_abc123"),
- Events: cercago.F("thread.created,thread.completed"),
- History: cercago.F(cercago.CellThreadEventListParamsHistoryTrue),
- Limit: cercago.F("20"),
+ "agent_abc123",
+ cercago.ApprovalListParams{
+ Cursor: cercago.F("cursor_abc123"),
+ Limit: cercago.F("20"),
+ ThreadID: cercago.F("thread_abc123"),
},
)
if err != nil {
@@ -45,7 +43,7 @@ func TestCellThreadEventListWithOptionalParams(t *testing.T) {
}
}
-func TestCellThreadEventSubscribe(t *testing.T) {
+func TestApprovalResolveWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -57,10 +55,15 @@ func TestCellThreadEventSubscribe(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Events.Subscribe(
+ _, err := client.Approvals.Resolve(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"thread_abc123",
+ "approval_abc123",
+ cercago.ApprovalResolveParams{
+ Decision: cercago.F(cercago.ApprovalResolveParamsDecisionApprove),
+ Grant: cercago.F(cercago.ApprovalResolveParamsGrantThread),
+ },
)
if err != nil {
var apierr *cercago.Error
diff --git a/approvalgrant.go b/approvalgrant.go
new file mode 100644
index 0000000..0f3d8ea
--- /dev/null
+++ b/approvalgrant.go
@@ -0,0 +1,244 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+)
+
+// ApprovalGrantService contains methods and other services that help with
+// interacting with the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewApprovalGrantService] method instead.
+type ApprovalGrantService struct {
+ Options []option.RequestOption
+}
+
+// NewApprovalGrantService generates a new service that applies the given options
+// to each request. These options are applied after the parent client's options (if
+// there is one), and before any request-specific options.
+func NewApprovalGrantService(opts ...option.RequestOption) (r *ApprovalGrantService) {
+ r = &ApprovalGrantService{}
+ r.Options = opts
+ return
+}
+
+func (r *ApprovalGrantService) List(ctx context.Context, agentID string, query ApprovalGrantListParams, opts ...option.RequestOption) (res *pagination.GrantsCursorPage[ApprovalGrant], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/approval-grants", agentID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ApprovalGrantService) ListAutoPaging(ctx context.Context, agentID string, query ApprovalGrantListParams, opts ...option.RequestOption) *pagination.GrantsCursorPageAutoPager[ApprovalGrant] {
+ return pagination.NewGrantsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
+}
+
+func (r *ApprovalGrantService) Delete(ctx context.Context, agentID string, grantID string, opts ...option.RequestOption) (res *ApprovalGrantDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if grantID == "" {
+ err = errors.New("missing required grantId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/approval-grants/%s", agentID, grantID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *ApprovalGrantService) DeleteForThread(ctx context.Context, agentID string, threadID string, grantID string, opts ...option.RequestOption) (res *ApprovalGrantDeleteForThreadResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ if grantID == "" {
+ err = errors.New("missing required grantId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/approval-grants/%s", agentID, threadID, grantID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *ApprovalGrantService) ListForThread(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (res *[]ApprovalGrant, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/approval-grants", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+type ApprovalGrant struct {
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ CreatedBy string `json:"createdBy" api:"required,nullable"`
+ ExpiresAt string `json:"expiresAt" api:"required,nullable"`
+ GrantKey string `json:"grantKey" api:"required"`
+ Scope ApprovalGrantScope `json:"scope" api:"required"`
+ JSON approvalGrantJSON `json:"-"`
+}
+
+// approvalGrantJSON contains the JSON metadata for the struct [ApprovalGrant]
+type approvalGrantJSON struct {
+ ID apijson.Field
+ CreatedAt apijson.Field
+ CreatedBy apijson.Field
+ ExpiresAt apijson.Field
+ GrantKey apijson.Field
+ Scope apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ApprovalGrant) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r approvalGrantJSON) RawJSON() string {
+ return r.raw
+}
+
+type ApprovalGrantScope string
+
+const (
+ ApprovalGrantScopeThread ApprovalGrantScope = "thread"
+ ApprovalGrantScopeAgent ApprovalGrantScope = "agent"
+)
+
+func (r ApprovalGrantScope) IsKnown() bool {
+ switch r {
+ case ApprovalGrantScopeThread, ApprovalGrantScopeAgent:
+ return true
+ }
+ return false
+}
+
+type ApprovalGrantDeleteResponse struct {
+ Ok ApprovalGrantDeleteResponseOk `json:"ok" api:"required"`
+ JSON approvalGrantDeleteResponseJSON `json:"-"`
+}
+
+// approvalGrantDeleteResponseJSON contains the JSON metadata for the struct
+// [ApprovalGrantDeleteResponse]
+type approvalGrantDeleteResponseJSON struct {
+ Ok apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ApprovalGrantDeleteResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r approvalGrantDeleteResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ApprovalGrantDeleteResponseOk bool
+
+const (
+ ApprovalGrantDeleteResponseOkTrue ApprovalGrantDeleteResponseOk = true
+)
+
+func (r ApprovalGrantDeleteResponseOk) IsKnown() bool {
+ switch r {
+ case ApprovalGrantDeleteResponseOkTrue:
+ return true
+ }
+ return false
+}
+
+type ApprovalGrantDeleteForThreadResponse struct {
+ Ok ApprovalGrantDeleteForThreadResponseOk `json:"ok" api:"required"`
+ JSON approvalGrantDeleteForThreadResponseJSON `json:"-"`
+}
+
+// approvalGrantDeleteForThreadResponseJSON contains the JSON metadata for the
+// struct [ApprovalGrantDeleteForThreadResponse]
+type approvalGrantDeleteForThreadResponseJSON struct {
+ Ok apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ApprovalGrantDeleteForThreadResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r approvalGrantDeleteForThreadResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ApprovalGrantDeleteForThreadResponseOk bool
+
+const (
+ ApprovalGrantDeleteForThreadResponseOkTrue ApprovalGrantDeleteForThreadResponseOk = true
+)
+
+func (r ApprovalGrantDeleteForThreadResponseOk) IsKnown() bool {
+ switch r {
+ case ApprovalGrantDeleteForThreadResponseOkTrue:
+ return true
+ }
+ return false
+}
+
+type ApprovalGrantListParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [ApprovalGrantListParams]'s query parameters as
+// `url.Values`.
+func (r ApprovalGrantListParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
diff --git a/cellcontextentry_test.go b/approvalgrant_test.go
similarity index 60%
rename from cellcontextentry_test.go
rename to approvalgrant_test.go
index 8df263b..75662f4 100644
--- a/cellcontextentry_test.go
+++ b/approvalgrant_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellContextEntryGet(t *testing.T) {
+func TestApprovalGrantListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,11 +25,12 @@ func TestCellContextEntryGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Context.Entries.Get(
+ _, err := client.ApprovalGrants.List(
context.TODO(),
- "cell_abc123",
- cercago.CellContextEntryGetParams{
- Key: cercago.F("notes/project.md"),
+ "agent_abc123",
+ cercago.ApprovalGrantListParams{
+ Cursor: cercago.F("cursor_abc123"),
+ Limit: cercago.F("20"),
},
)
if err != nil {
@@ -41,7 +42,7 @@ func TestCellContextEntryGet(t *testing.T) {
}
}
-func TestCellContextEntryDelete(t *testing.T) {
+func TestApprovalGrantDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -53,12 +54,10 @@ func TestCellContextEntryDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Context.Entries.Delete(
+ _, err := client.ApprovalGrants.Delete(
context.TODO(),
- "cell_abc123",
- cercago.CellContextEntryDeleteParams{
- Key: cercago.F("notes/project.md"),
- },
+ "agent_abc123",
+ "grant_abc123",
)
if err != nil {
var apierr *cercago.Error
@@ -69,7 +68,7 @@ func TestCellContextEntryDelete(t *testing.T) {
}
}
-func TestCellContextEntryPutWithOptionalParams(t *testing.T) {
+func TestApprovalGrantDeleteForThread(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -81,15 +80,37 @@ func TestCellContextEntryPutWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Context.Entries.Put(
+ _, err := client.ApprovalGrants.DeleteForThread(
context.TODO(),
- "cell_abc123",
- cercago.CellContextEntryPutParams{
- Content: cercago.F("content"),
- Key: cercago.F("key"),
- ExpectedVersion: cercago.F(0.000000),
- MimeType: cercago.F("mimeType"),
- },
+ "agent_abc123",
+ "thread_abc123",
+ "grant_abc123",
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestApprovalGrantListForThread(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.ApprovalGrants.ListForThread(
+ context.TODO(),
+ "agent_abc123",
+ "thread_abc123",
)
if err != nil {
var apierr *cercago.Error
diff --git a/auth.go b/auth.go
index 27378f9..79e6322 100644
--- a/auth.go
+++ b/auth.go
@@ -13,6 +13,7 @@ import (
"github.com/matrices/cerca-go/internal/param"
"github.com/matrices/cerca-go/internal/requestconfig"
"github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
)
// AuthService contains methods and other services that help with interacting with
@@ -41,11 +42,25 @@ func (r *AuthService) Context(ctx context.Context, opts ...option.RequestOption)
return res, err
}
-func (r *AuthService) ListEnvironments(ctx context.Context, query AuthListEnvironmentsParams, opts ...option.RequestOption) (res *AuthListEnvironmentsResponse, err error) {
+func (r *AuthService) ListFleets(ctx context.Context, query AuthListFleetsParams, opts ...option.RequestOption) (res *pagination.FleetsCursorPage[Fleet], err error) {
+ var raw *http.Response
opts = slices.Concat(r.Options, opts)
- path := "auth/environments"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ path := "auth/fleets"
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *AuthService) ListFleetsAutoPaging(ctx context.Context, query AuthListFleetsParams, opts ...option.RequestOption) *pagination.FleetsCursorPageAutoPager[Fleet] {
+ return pagination.NewFleetsCursorPageAutoPager(r.ListFleets(ctx, query, opts...))
}
type AuthContextResponse struct {
@@ -71,32 +86,32 @@ func (r authContextResponseJSON) RawJSON() string {
return r.raw
}
-type AuthListEnvironmentsResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- Environments []Environment `json:"environments" api:"required"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON authListEnvironmentsResponseJSON `json:"-"`
+type AuthFleetsResponse struct {
+ Cursor string `json:"cursor" api:"required,nullable"`
+ Fleets []Fleet `json:"fleets" api:"required"`
+ HasMore bool `json:"hasMore" api:"required"`
+ JSON authFleetsResponseJSON `json:"-"`
}
-// authListEnvironmentsResponseJSON contains the JSON metadata for the struct
-// [AuthListEnvironmentsResponse]
-type authListEnvironmentsResponseJSON struct {
- Cursor apijson.Field
- Environments apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
+// authFleetsResponseJSON contains the JSON metadata for the struct
+// [AuthFleetsResponse]
+type authFleetsResponseJSON struct {
+ Cursor apijson.Field
+ Fleets apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
}
-func (r *AuthListEnvironmentsResponse) UnmarshalJSON(data []byte) (err error) {
+func (r *AuthFleetsResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r authListEnvironmentsResponseJSON) RawJSON() string {
+func (r authFleetsResponseJSON) RawJSON() string {
return r.raw
}
-type AuthListEnvironmentsParams struct {
+type AuthListFleetsParams struct {
// Opaque pagination cursor returned by a previous request.
Cursor param.Field[string] `query:"cursor"`
// Maximum number of items to return. Defaults to 20 and preserves parseInt
@@ -104,9 +119,8 @@ type AuthListEnvironmentsParams struct {
Limit param.Field[string] `query:"limit"`
}
-// URLQuery serializes [AuthListEnvironmentsParams]'s query parameters as
-// `url.Values`.
-func (r AuthListEnvironmentsParams) URLQuery() (v url.Values) {
+// URLQuery serializes [AuthListFleetsParams]'s query parameters as `url.Values`.
+func (r AuthListFleetsParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
diff --git a/auth_test.go b/auth_test.go
index 69aa40c..4b5c020 100644
--- a/auth_test.go
+++ b/auth_test.go
@@ -35,7 +35,7 @@ func TestAuthContext(t *testing.T) {
}
}
-func TestAuthListEnvironmentsWithOptionalParams(t *testing.T) {
+func TestAuthListFleetsWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -47,7 +47,7 @@ func TestAuthListEnvironmentsWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Auth.ListEnvironments(context.TODO(), cercago.AuthListEnvironmentsParams{
+ _, err := client.Auth.ListFleets(context.TODO(), cercago.AuthListFleetsParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
})
diff --git a/cell.go b/cell.go
deleted file mode 100644
index 1367327..0000000
--- a/cell.go
+++ /dev/null
@@ -1,529 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "reflect"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
- "github.com/tidwall/gjson"
-)
-
-// CellService contains methods and other services that help with interacting with
-// the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellService] method instead.
-type CellService struct {
- Options []option.RequestOption
- Config *CellConfigService
- Metadata *CellMetadataService
- Tools *CellToolService
- ToolSources *CellToolSourceService
- Context *CellContextService
- Connections *CellConnectionService
- Schedules *CellScheduleService
- Threads *CellThreadService
- Approvals *CellApprovalService
- ApprovalGrants *CellApprovalGrantService
- Logs *CellLogService
- Sandbox *CellSandboxService
- Events *CellEventService
-}
-
-// NewCellService generates a new service that applies the given options to each
-// request. These options are applied after the parent client's options (if there
-// is one), and before any request-specific options.
-func NewCellService(opts ...option.RequestOption) (r *CellService) {
- r = &CellService{}
- r.Options = opts
- r.Config = NewCellConfigService(opts...)
- r.Metadata = NewCellMetadataService(opts...)
- r.Tools = NewCellToolService(opts...)
- r.ToolSources = NewCellToolSourceService(opts...)
- r.Context = NewCellContextService(opts...)
- r.Connections = NewCellConnectionService(opts...)
- r.Schedules = NewCellScheduleService(opts...)
- r.Threads = NewCellThreadService(opts...)
- r.Approvals = NewCellApprovalService(opts...)
- r.ApprovalGrants = NewCellApprovalGrantService(opts...)
- r.Logs = NewCellLogService(opts...)
- r.Sandbox = NewCellSandboxService(opts...)
- r.Events = NewCellEventService(opts...)
- return
-}
-
-func (r *CellService) New(ctx context.Context, body CellNewParams, opts ...option.RequestOption) (res *Cell, err error) {
- opts = slices.Concat(r.Options, opts)
- path := "cells"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellService) Get(ctx context.Context, cellID string, opts ...option.RequestOption) (res *Cell, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *CellService) Update(ctx context.Context, cellID string, body CellUpdateParams, opts ...option.RequestOption) (res *Cell, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellService) List(ctx context.Context, query CellListParams, opts ...option.RequestOption) (res *CellListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- path := "cells"
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-func (r *CellService) Delete(ctx context.Context, cellID string, opts ...option.RequestOption) (res *CellDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
- return res, err
-}
-
-type Cell struct {
- ID string `json:"id" api:"required"`
- Configuration CellConfiguration `json:"configuration" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- EnvironmentID string `json:"environmentId" api:"required"`
- ExecutionPrincipal ExecutionPrincipal `json:"executionPrincipal" api:"required,nullable"`
- // Arbitrary string metadata stored on a cell. Runtime enforces maximum key and
- // value sizes.
- Metadata CellMetadata `json:"metadata" api:"required"`
- OrgID string `json:"orgId" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- UserID string `json:"userId" api:"required"`
- JSON cellJSON `json:"-"`
-}
-
-// cellJSON contains the JSON metadata for the struct [Cell]
-type cellJSON struct {
- ID apijson.Field
- Configuration apijson.Field
- CreatedAt apijson.Field
- EnvironmentID apijson.Field
- ExecutionPrincipal apijson.Field
- Metadata apijson.Field
- OrgID apijson.Field
- UpdatedAt apijson.Field
- UserID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *Cell) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellJSON) RawJSON() string {
- return r.raw
-}
-
-type CellConfiguration struct {
- ApprovalRequired []RuntimeToolName `json:"approvalRequired"`
- ApprovalTimeoutMs float64 `json:"approvalTimeoutMs"`
- DefaultModel string `json:"defaultModel"`
- ExcludedToolSourceIDs []string `json:"excludedToolSourceIds"`
- Features []CellConfigurationFeature `json:"features"`
- Instructions string `json:"instructions"`
- ToolApprovalOverrides map[string]RuntimeToolApprovalOverrideMode `json:"toolApprovalOverrides"`
- ToolSourceMode CellConfigurationToolSourceMode `json:"toolSourceMode"`
- UserContext string `json:"userContext"`
- JSON cellConfigurationJSON `json:"-"`
-}
-
-// cellConfigurationJSON contains the JSON metadata for the struct
-// [CellConfiguration]
-type cellConfigurationJSON struct {
- ApprovalRequired apijson.Field
- ApprovalTimeoutMs apijson.Field
- DefaultModel apijson.Field
- ExcludedToolSourceIDs apijson.Field
- Features apijson.Field
- Instructions apijson.Field
- ToolApprovalOverrides apijson.Field
- ToolSourceMode apijson.Field
- UserContext apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellConfiguration) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellConfigurationJSON) RawJSON() string {
- return r.raw
-}
-
-type CellConfigurationFeature string
-
-const (
- CellConfigurationFeatureMemory CellConfigurationFeature = "memory"
- CellConfigurationFeatureSandbox CellConfigurationFeature = "sandbox"
- CellConfigurationFeatureWeb CellConfigurationFeature = "web"
- CellConfigurationFeatureConnections CellConfigurationFeature = "connections"
- CellConfigurationFeatureOAuthConnect CellConfigurationFeature = "oauth_connect"
-)
-
-func (r CellConfigurationFeature) IsKnown() bool {
- switch r {
- case CellConfigurationFeatureMemory, CellConfigurationFeatureSandbox, CellConfigurationFeatureWeb, CellConfigurationFeatureConnections, CellConfigurationFeatureOAuthConnect:
- return true
- }
- return false
-}
-
-type CellConfigurationToolSourceMode string
-
-const (
- CellConfigurationToolSourceModeInherit CellConfigurationToolSourceMode = "inherit"
- CellConfigurationToolSourceModeExplicit CellConfigurationToolSourceMode = "explicit"
-)
-
-func (r CellConfigurationToolSourceMode) IsKnown() bool {
- switch r {
- case CellConfigurationToolSourceModeInherit, CellConfigurationToolSourceModeExplicit:
- return true
- }
- return false
-}
-
-type CellConfigurationParam struct {
- ApprovalRequired param.Field[[]RuntimeToolName] `json:"approvalRequired"`
- ApprovalTimeoutMs param.Field[float64] `json:"approvalTimeoutMs"`
- DefaultModel param.Field[string] `json:"defaultModel"`
- ExcludedToolSourceIDs param.Field[[]string] `json:"excludedToolSourceIds"`
- Features param.Field[[]CellConfigurationFeature] `json:"features"`
- Instructions param.Field[string] `json:"instructions"`
- ToolApprovalOverrides param.Field[map[string]RuntimeToolApprovalOverrideMode] `json:"toolApprovalOverrides"`
- ToolSourceMode param.Field[CellConfigurationToolSourceMode] `json:"toolSourceMode"`
- UserContext param.Field[string] `json:"userContext"`
-}
-
-func (r CellConfigurationParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellMetadata map[string]string
-
-type CellMetadataParam map[string]string
-
-type CellSummary struct {
- ID string `json:"id" api:"required"`
- ActiveThreadCount float64 `json:"activeThreadCount" api:"required"`
- AwaitingThreadCount float64 `json:"awaitingThreadCount" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- DefaultModel string `json:"defaultModel" api:"required,nullable"`
- EnvironmentID string `json:"environmentId" api:"required"`
- // Arbitrary string metadata stored on a cell. Runtime enforces maximum key and
- // value sizes.
- Metadata CellMetadata `json:"metadata" api:"required"`
- OrgID string `json:"orgId" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- UserID string `json:"userId" api:"required"`
- JSON cellSummaryJSON `json:"-"`
-}
-
-// cellSummaryJSON contains the JSON metadata for the struct [CellSummary]
-type cellSummaryJSON struct {
- ID apijson.Field
- ActiveThreadCount apijson.Field
- AwaitingThreadCount apijson.Field
- CreatedAt apijson.Field
- DefaultModel apijson.Field
- EnvironmentID apijson.Field
- Metadata apijson.Field
- OrgID apijson.Field
- UpdatedAt apijson.Field
- UserID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellSummary) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellSummaryJSON) RawJSON() string {
- return r.raw
-}
-
-type ExecutionPrincipal struct {
- Kind ExecutionPrincipalKind `json:"kind" api:"required"`
- EnvID string `json:"envId" api:"nullable"`
- KeyID string `json:"keyId"`
- UserID string `json:"userId"`
- JSON executionPrincipalJSON `json:"-"`
- union ExecutionPrincipalUnion
-}
-
-// executionPrincipalJSON contains the JSON metadata for the struct
-// [ExecutionPrincipal]
-type executionPrincipalJSON struct {
- Kind apijson.Field
- EnvID apijson.Field
- KeyID apijson.Field
- UserID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r executionPrincipalJSON) RawJSON() string {
- return r.raw
-}
-
-func (r *ExecutionPrincipal) UnmarshalJSON(data []byte) (err error) {
- *r = ExecutionPrincipal{}
- err = apijson.UnmarshalRoot(data, &r.union)
- if err != nil {
- return err
- }
- return apijson.Port(r.union, &r)
-}
-
-// AsUnion returns a [ExecutionPrincipalUnion] interface which you can cast to the
-// specific types for more type safety.
-//
-// Possible runtime types of the union are [ExecutionPrincipalObject],
-// [ExecutionPrincipalObject].
-func (r ExecutionPrincipal) AsUnion() ExecutionPrincipalUnion {
- return r.union
-}
-
-// Union satisfied by [ExecutionPrincipalObject] or [ExecutionPrincipalObject].
-type ExecutionPrincipalUnion interface {
- implementsExecutionPrincipal()
-}
-
-func init() {
- apijson.RegisterUnion(
- reflect.TypeOf((*ExecutionPrincipalUnion)(nil)).Elem(),
- "",
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ExecutionPrincipalObject{}),
- },
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ExecutionPrincipalObject{}),
- },
- )
-}
-
-type ExecutionPrincipalObject struct {
- Kind ExecutionPrincipalObjectKind `json:"kind" api:"required"`
- UserID string `json:"userId" api:"required"`
- JSON executionPrincipalObjectJSON `json:"-"`
-}
-
-// executionPrincipalObjectJSON contains the JSON metadata for the struct
-// [ExecutionPrincipalObject]
-type executionPrincipalObjectJSON struct {
- Kind apijson.Field
- UserID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ExecutionPrincipalObject) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r executionPrincipalObjectJSON) RawJSON() string {
- return r.raw
-}
-
-func (r ExecutionPrincipalObject) implementsExecutionPrincipal() {}
-
-type ExecutionPrincipalObjectKind string
-
-const (
- ExecutionPrincipalObjectKindUser ExecutionPrincipalObjectKind = "user"
-)
-
-func (r ExecutionPrincipalObjectKind) IsKnown() bool {
- switch r {
- case ExecutionPrincipalObjectKindUser:
- return true
- }
- return false
-}
-
-type ExecutionPrincipalKind string
-
-const (
- ExecutionPrincipalKindUser ExecutionPrincipalKind = "user"
- ExecutionPrincipalKindAPIKey ExecutionPrincipalKind = "apiKey"
-)
-
-func (r ExecutionPrincipalKind) IsKnown() bool {
- switch r {
- case ExecutionPrincipalKindUser, ExecutionPrincipalKindAPIKey:
- return true
- }
- return false
-}
-
-type RuntimeToolApprovalOverrideMode string
-
-const (
- RuntimeToolApprovalOverrideModeAlways RuntimeToolApprovalOverrideMode = "always"
- RuntimeToolApprovalOverrideModeNever RuntimeToolApprovalOverrideMode = "never"
-)
-
-func (r RuntimeToolApprovalOverrideMode) IsKnown() bool {
- switch r {
- case RuntimeToolApprovalOverrideModeAlways, RuntimeToolApprovalOverrideModeNever:
- return true
- }
- return false
-}
-
-type CellListResponse struct {
- Cells []CellSummary `json:"cells" api:"required"`
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON cellListResponseJSON `json:"-"`
-}
-
-// cellListResponseJSON contains the JSON metadata for the struct
-// [CellListResponse]
-type cellListResponseJSON struct {
- Cells apijson.Field
- Cursor apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellDeleteResponse struct {
- Success CellDeleteResponseSuccess `json:"success" api:"required"`
- JSON cellDeleteResponseJSON `json:"-"`
-}
-
-// cellDeleteResponseJSON contains the JSON metadata for the struct
-// [CellDeleteResponse]
-type cellDeleteResponseJSON struct {
- Success apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellDeleteResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellDeleteResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellDeleteResponseSuccess bool
-
-const (
- CellDeleteResponseSuccessTrue CellDeleteResponseSuccess = true
-)
-
-func (r CellDeleteResponseSuccess) IsKnown() bool {
- switch r {
- case CellDeleteResponseSuccessTrue:
- return true
- }
- return false
-}
-
-type CellNewParams struct {
- UserID param.Field[string] `json:"userId" api:"required"`
- Configuration param.Field[CellConfigurationParam] `json:"configuration"`
- EnvironmentID param.Field[string] `json:"environmentId"`
- // Arbitrary string metadata stored on a cell. Runtime enforces maximum key and
- // value sizes.
- Metadata param.Field[CellMetadataParam] `json:"metadata"`
-}
-
-func (r CellNewParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellUpdateParams struct {
- Configuration param.Field[CellConfigurationParam] `json:"configuration" api:"required"`
-}
-
-func (r CellUpdateParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellListParams struct {
- // When set to true, lists only cells with active or awaiting threads.
- Active param.Field[CellListParamsActive] `query:"active"`
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Environment to list cells from. Defaults to the API key's default environment
- // when omitted.
- EnvironmentID param.Field[string] `query:"environmentId"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [CellListParams]'s query parameters as `url.Values`.
-func (r CellListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-// When set to true, lists only cells with active or awaiting threads.
-type CellListParamsActive string
-
-const (
- CellListParamsActiveTrue CellListParamsActive = "true"
- CellListParamsActiveFalse CellListParamsActive = "false"
-)
-
-func (r CellListParamsActive) IsKnown() bool {
- switch r {
- case CellListParamsActiveTrue, CellListParamsActiveFalse:
- return true
- }
- return false
-}
diff --git a/cellapproval_test.go b/cellapproval_test.go
deleted file mode 100644
index ebadece..0000000
--- a/cellapproval_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCellApprovalListWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Approvals.List(
- context.TODO(),
- "cell_abc123",
- cercago.CellApprovalListParams{
- Cursor: cercago.F("cursor_abc123"),
- Limit: cercago.F("20"),
- ThreadID: cercago.F("thread_abc123"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/cellapprovalgrant.go b/cellapprovalgrant.go
deleted file mode 100644
index 92017c1..0000000
--- a/cellapprovalgrant.go
+++ /dev/null
@@ -1,185 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellApprovalGrantService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellApprovalGrantService] method instead.
-type CellApprovalGrantService struct {
- Options []option.RequestOption
-}
-
-// NewCellApprovalGrantService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewCellApprovalGrantService(opts ...option.RequestOption) (r *CellApprovalGrantService) {
- r = &CellApprovalGrantService{}
- r.Options = opts
- return
-}
-
-func (r *CellApprovalGrantService) List(ctx context.Context, cellID string, query CellApprovalGrantListParams, opts ...option.RequestOption) (res *CellApprovalGrantListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/approval-grants", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-func (r *CellApprovalGrantService) Delete(ctx context.Context, cellID string, grantID string, opts ...option.RequestOption) (res *CellApprovalGrantDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if grantID == "" {
- err = errors.New("missing required grantId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/approval-grants/%s", cellID, grantID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
- return res, err
-}
-
-type ApprovalGrant struct {
- ID string `json:"id" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- CreatedBy string `json:"createdBy" api:"required,nullable"`
- ExpiresAt string `json:"expiresAt" api:"required,nullable"`
- GrantKey string `json:"grantKey" api:"required"`
- Scope ApprovalGrantScope `json:"scope" api:"required"`
- JSON approvalGrantJSON `json:"-"`
-}
-
-// approvalGrantJSON contains the JSON metadata for the struct [ApprovalGrant]
-type approvalGrantJSON struct {
- ID apijson.Field
- CreatedAt apijson.Field
- CreatedBy apijson.Field
- ExpiresAt apijson.Field
- GrantKey apijson.Field
- Scope apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ApprovalGrant) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r approvalGrantJSON) RawJSON() string {
- return r.raw
-}
-
-type ApprovalGrantScope string
-
-const (
- ApprovalGrantScopeThread ApprovalGrantScope = "thread"
- ApprovalGrantScopeCell ApprovalGrantScope = "cell"
-)
-
-func (r ApprovalGrantScope) IsKnown() bool {
- switch r {
- case ApprovalGrantScopeThread, ApprovalGrantScopeCell:
- return true
- }
- return false
-}
-
-type CellApprovalGrantListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- Grants []ApprovalGrant `json:"grants" api:"required"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON cellApprovalGrantListResponseJSON `json:"-"`
-}
-
-// cellApprovalGrantListResponseJSON contains the JSON metadata for the struct
-// [CellApprovalGrantListResponse]
-type cellApprovalGrantListResponseJSON struct {
- Cursor apijson.Field
- Grants apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellApprovalGrantListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellApprovalGrantListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellApprovalGrantDeleteResponse struct {
- Ok CellApprovalGrantDeleteResponseOk `json:"ok" api:"required"`
- JSON cellApprovalGrantDeleteResponseJSON `json:"-"`
-}
-
-// cellApprovalGrantDeleteResponseJSON contains the JSON metadata for the struct
-// [CellApprovalGrantDeleteResponse]
-type cellApprovalGrantDeleteResponseJSON struct {
- Ok apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellApprovalGrantDeleteResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellApprovalGrantDeleteResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellApprovalGrantDeleteResponseOk bool
-
-const (
- CellApprovalGrantDeleteResponseOkTrue CellApprovalGrantDeleteResponseOk = true
-)
-
-func (r CellApprovalGrantDeleteResponseOk) IsKnown() bool {
- switch r {
- case CellApprovalGrantDeleteResponseOkTrue:
- return true
- }
- return false
-}
-
-type CellApprovalGrantListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [CellApprovalGrantListParams]'s query parameters as
-// `url.Values`.
-func (r CellApprovalGrantListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/cellapprovalgrant_test.go b/cellapprovalgrant_test.go
deleted file mode 100644
index 34cc0ab..0000000
--- a/cellapprovalgrant_test.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCellApprovalGrantListWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.ApprovalGrants.List(
- context.TODO(),
- "cell_abc123",
- cercago.CellApprovalGrantListParams{
- Cursor: cercago.F("cursor_abc123"),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestCellApprovalGrantDelete(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.ApprovalGrants.Delete(
- context.TODO(),
- "cell_abc123",
- "grant_abc123",
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/cellconfig.go b/cellconfig.go
deleted file mode 100644
index 95acf67..0000000
--- a/cellconfig.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "slices"
-
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellConfigService contains methods and other services that help with interacting
-// with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellConfigService] method instead.
-type CellConfigService struct {
- Options []option.RequestOption
-}
-
-// NewCellConfigService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellConfigService(opts ...option.RequestOption) (r *CellConfigService) {
- r = &CellConfigService{}
- r.Options = opts
- return
-}
-
-func (r *CellConfigService) Get(ctx context.Context, cellID string, opts ...option.RequestOption) (res *CellConfiguration, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/config", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
diff --git a/cellconnection.go b/cellconnection.go
deleted file mode 100644
index b202ddb..0000000
--- a/cellconnection.go
+++ /dev/null
@@ -1,169 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellConnectionService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellConnectionService] method instead.
-type CellConnectionService struct {
- Options []option.RequestOption
-}
-
-// NewCellConnectionService generates a new service that applies the given options
-// to each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellConnectionService(opts ...option.RequestOption) (r *CellConnectionService) {
- r = &CellConnectionService{}
- r.Options = opts
- return
-}
-
-func (r *CellConnectionService) List(ctx context.Context, cellID string, opts ...option.RequestOption) (res *CellConnectionListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/connections", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *CellConnectionService) Attach(ctx context.Context, cellID string, body CellConnectionAttachParams, opts ...option.RequestOption) (res *AttachedConnection, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/connections", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellConnectionService) Detach(ctx context.Context, cellID string, connectionID string, opts ...option.RequestOption) (res *CellConnectionDetachResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if connectionID == "" {
- err = errors.New("missing required connectionId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/connections/%s", cellID, connectionID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
- return res, err
-}
-
-type AttachedConnection struct {
- AttachedAt string `json:"attachedAt" api:"required"`
- Metadata ToolConnectionMetadata `json:"metadata"`
- JSON attachedConnectionJSON `json:"-"`
- Connection
-}
-
-// attachedConnectionJSON contains the JSON metadata for the struct
-// [AttachedConnection]
-type attachedConnectionJSON struct {
- AttachedAt apijson.Field
- Metadata apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *AttachedConnection) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r attachedConnectionJSON) RawJSON() string {
- return r.raw
-}
-
-type ToolConnectionMetadata map[string]string
-
-type ToolConnectionMetadataParam map[string]string
-
-type CellConnectionListResponse struct {
- Connections []AttachedConnection `json:"connections" api:"required"`
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON cellConnectionListResponseJSON `json:"-"`
-}
-
-// cellConnectionListResponseJSON contains the JSON metadata for the struct
-// [CellConnectionListResponse]
-type cellConnectionListResponseJSON struct {
- Connections apijson.Field
- Cursor apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellConnectionListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellConnectionListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellConnectionDetachResponse struct {
- Success CellConnectionDetachResponseSuccess `json:"success" api:"required"`
- JSON cellConnectionDetachResponseJSON `json:"-"`
-}
-
-// cellConnectionDetachResponseJSON contains the JSON metadata for the struct
-// [CellConnectionDetachResponse]
-type cellConnectionDetachResponseJSON struct {
- Success apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellConnectionDetachResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellConnectionDetachResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellConnectionDetachResponseSuccess bool
-
-const (
- CellConnectionDetachResponseSuccessTrue CellConnectionDetachResponseSuccess = true
-)
-
-func (r CellConnectionDetachResponseSuccess) IsKnown() bool {
- switch r {
- case CellConnectionDetachResponseSuccessTrue:
- return true
- }
- return false
-}
-
-type CellConnectionAttachParams struct {
- ConnectionID param.Field[string] `json:"connectionId" api:"required"`
- Metadata param.Field[ToolConnectionMetadataParam] `json:"metadata"`
-}
-
-func (r CellConnectionAttachParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
diff --git a/cellcontext.go b/cellcontext.go
deleted file mode 100644
index ec38bf3..0000000
--- a/cellcontext.go
+++ /dev/null
@@ -1,240 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellContextService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellContextService] method instead.
-type CellContextService struct {
- Options []option.RequestOption
- Entries *CellContextEntryService
-}
-
-// NewCellContextService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellContextService(opts ...option.RequestOption) (r *CellContextService) {
- r = &CellContextService{}
- r.Options = opts
- r.Entries = NewCellContextEntryService(opts...)
- return
-}
-
-func (r *CellContextService) List(ctx context.Context, cellID string, query CellContextListParams, opts ...option.RequestOption) (res *CellContextListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/context", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-func (r *CellContextService) Search(ctx context.Context, cellID string, query CellContextSearchParams, opts ...option.RequestOption) (res *CellContextSearchResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/context/search", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-type ContextEntry struct {
- Content string `json:"content" api:"required"`
- Key string `json:"key" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Version float64 `json:"version" api:"required"`
- MimeType string `json:"mimeType"`
- JSON contextEntryJSON `json:"-"`
-}
-
-// contextEntryJSON contains the JSON metadata for the struct [ContextEntry]
-type contextEntryJSON struct {
- Content apijson.Field
- Key apijson.Field
- UpdatedAt apijson.Field
- Version apijson.Field
- MimeType apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ContextEntry) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r contextEntryJSON) RawJSON() string {
- return r.raw
-}
-
-type ContextEntrySummary struct {
- ByteLength float64 `json:"byteLength" api:"required"`
- Key string `json:"key" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Version float64 `json:"version" api:"required"`
- MimeType string `json:"mimeType"`
- JSON contextEntrySummaryJSON `json:"-"`
-}
-
-// contextEntrySummaryJSON contains the JSON metadata for the struct
-// [ContextEntrySummary]
-type contextEntrySummaryJSON struct {
- ByteLength apijson.Field
- Key apijson.Field
- UpdatedAt apijson.Field
- Version apijson.Field
- MimeType apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ContextEntrySummary) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r contextEntrySummaryJSON) RawJSON() string {
- return r.raw
-}
-
-type ContextSearchResult struct {
- ByteLength float64 `json:"byteLength" api:"required"`
- Key string `json:"key" api:"required"`
- Score float64 `json:"score" api:"required"`
- Snippet string `json:"snippet" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Version float64 `json:"version" api:"required"`
- MimeType string `json:"mimeType"`
- JSON contextSearchResultJSON `json:"-"`
-}
-
-// contextSearchResultJSON contains the JSON metadata for the struct
-// [ContextSearchResult]
-type contextSearchResultJSON struct {
- ByteLength apijson.Field
- Key apijson.Field
- Score apijson.Field
- Snippet apijson.Field
- UpdatedAt apijson.Field
- Version apijson.Field
- MimeType apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ContextSearchResult) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r contextSearchResultJSON) RawJSON() string {
- return r.raw
-}
-
-type CellContextListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- Entries []ContextEntrySummary `json:"entries" api:"required"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON cellContextListResponseJSON `json:"-"`
-}
-
-// cellContextListResponseJSON contains the JSON metadata for the struct
-// [CellContextListResponse]
-type cellContextListResponseJSON struct {
- Cursor apijson.Field
- Entries apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellContextListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellContextListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellContextSearchResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- Results []ContextSearchResult `json:"results" api:"required"`
- JSON cellContextSearchResponseJSON `json:"-"`
-}
-
-// cellContextSearchResponseJSON contains the JSON metadata for the struct
-// [CellContextSearchResponse]
-type cellContextSearchResponseJSON struct {
- Cursor apijson.Field
- HasMore apijson.Field
- Results apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellContextSearchResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellContextSearchResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellContextListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
- // Optional key prefix filter.
- Prefix param.Field[string] `query:"prefix"`
-}
-
-// URLQuery serializes [CellContextListParams]'s query parameters as `url.Values`.
-func (r CellContextListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type CellContextSearchParams struct {
- // Search query.
- Q param.Field[string] `query:"q" api:"required"`
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
- // Optional key prefix filter.
- Prefix param.Field[string] `query:"prefix"`
-}
-
-// URLQuery serializes [CellContextSearchParams]'s query parameters as
-// `url.Values`.
-func (r CellContextSearchParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/cellcontextentry.go b/cellcontextentry.go
deleted file mode 100644
index d22d351..0000000
--- a/cellcontextentry.go
+++ /dev/null
@@ -1,144 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellContextEntryService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellContextEntryService] method instead.
-type CellContextEntryService struct {
- Options []option.RequestOption
-}
-
-// NewCellContextEntryService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewCellContextEntryService(opts ...option.RequestOption) (r *CellContextEntryService) {
- r = &CellContextEntryService{}
- r.Options = opts
- return
-}
-
-func (r *CellContextEntryService) Get(ctx context.Context, cellID string, query CellContextEntryGetParams, opts ...option.RequestOption) (res *ContextEntry, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/context/entry", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-func (r *CellContextEntryService) Delete(ctx context.Context, cellID string, body CellContextEntryDeleteParams, opts ...option.RequestOption) (res *CellContextEntryDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/context/entry", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellContextEntryService) Put(ctx context.Context, cellID string, body CellContextEntryPutParams, opts ...option.RequestOption) (res *ContextEntry, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/context/entry", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
- return res, err
-}
-
-type CellContextEntryDeleteResponse struct {
- Success CellContextEntryDeleteResponseSuccess `json:"success" api:"required"`
- JSON cellContextEntryDeleteResponseJSON `json:"-"`
-}
-
-// cellContextEntryDeleteResponseJSON contains the JSON metadata for the struct
-// [CellContextEntryDeleteResponse]
-type cellContextEntryDeleteResponseJSON struct {
- Success apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellContextEntryDeleteResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellContextEntryDeleteResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellContextEntryDeleteResponseSuccess bool
-
-const (
- CellContextEntryDeleteResponseSuccessTrue CellContextEntryDeleteResponseSuccess = true
-)
-
-func (r CellContextEntryDeleteResponseSuccess) IsKnown() bool {
- switch r {
- case CellContextEntryDeleteResponseSuccessTrue:
- return true
- }
- return false
-}
-
-type CellContextEntryGetParams struct {
- // Context entry key.
- Key param.Field[string] `query:"key" api:"required"`
-}
-
-// URLQuery serializes [CellContextEntryGetParams]'s query parameters as
-// `url.Values`.
-func (r CellContextEntryGetParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type CellContextEntryDeleteParams struct {
- // Context entry key.
- Key param.Field[string] `query:"key" api:"required"`
-}
-
-// URLQuery serializes [CellContextEntryDeleteParams]'s query parameters as
-// `url.Values`.
-func (r CellContextEntryDeleteParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type CellContextEntryPutParams struct {
- Content param.Field[string] `json:"content" api:"required"`
- Key param.Field[string] `json:"key" api:"required"`
- ExpectedVersion param.Field[float64] `json:"expectedVersion"`
- MimeType param.Field[string] `json:"mimeType"`
-}
-
-func (r CellContextEntryPutParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
diff --git a/cellevent.go b/cellevent.go
deleted file mode 100644
index 91fa95b..0000000
--- a/cellevent.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellEventService contains methods and other services that help with interacting
-// with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellEventService] method instead.
-type CellEventService struct {
- Options []option.RequestOption
-}
-
-// NewCellEventService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellEventService(opts ...option.RequestOption) (r *CellEventService) {
- r = &CellEventService{}
- r.Options = opts
- return
-}
-
-func (r *CellEventService) List(ctx context.Context, cellID string, query CellEventListParams, opts ...option.RequestOption) (res *CellEventListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/events", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// WebSocket upgrade endpoint. Set
-// `Sec-WebSocket-Protocol: cell-v1, cell-auth-` so the runtime can
-// authenticate the stream while preserving the public subprotocol. HTTP clients
-// that cannot upgrade should use `/cells/{cellId}/events` as the polling analog.
-func (r *CellEventService) Subscribe(ctx context.Context, cellID string, opts ...option.RequestOption) (res *CellEventSubscribeResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/events/subscribe", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-type CellEventListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- Events []SubscriptionEvent `json:"events" api:"required"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON cellEventListResponseJSON `json:"-"`
-}
-
-// cellEventListResponseJSON contains the JSON metadata for the struct
-// [CellEventListResponse]
-type cellEventListResponseJSON struct {
- Cursor apijson.Field
- Events apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellEventListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellEventListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellEventSubscribeResponse struct {
- Error string `json:"error" api:"required"`
- JSON cellEventSubscribeResponseJSON `json:"-"`
-}
-
-// cellEventSubscribeResponseJSON contains the JSON metadata for the struct
-// [CellEventSubscribeResponse]
-type cellEventSubscribeResponseJSON struct {
- Error apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellEventSubscribeResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellEventSubscribeResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellEventListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Comma-separated event type filter.
- Events param.Field[string] `query:"events"`
- // When true, starts from the beginning of the retained buffer.
- History param.Field[CellEventListParamsHistory] `query:"history"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [CellEventListParams]'s query parameters as `url.Values`.
-func (r CellEventListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-// When true, starts from the beginning of the retained buffer.
-type CellEventListParamsHistory string
-
-const (
- CellEventListParamsHistoryTrue CellEventListParamsHistory = "true"
- CellEventListParamsHistoryFalse CellEventListParamsHistory = "false"
-)
-
-func (r CellEventListParamsHistory) IsKnown() bool {
- switch r {
- case CellEventListParamsHistoryTrue, CellEventListParamsHistoryFalse:
- return true
- }
- return false
-}
diff --git a/cellevent_test.go b/cellevent_test.go
deleted file mode 100644
index 27c90e2..0000000
--- a/cellevent_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCellEventListWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Events.List(
- context.TODO(),
- "cell_abc123",
- cercago.CellEventListParams{
- Cursor: cercago.F("cursor_abc123"),
- Events: cercago.F("thread.created,thread.completed"),
- History: cercago.F(cercago.CellEventListParamsHistoryTrue),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestCellEventSubscribe(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Events.Subscribe(context.TODO(), "cell_abc123")
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/celllog.go b/celllog.go
deleted file mode 100644
index 62e7bd0..0000000
--- a/celllog.go
+++ /dev/null
@@ -1,89 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellLogService contains methods and other services that help with interacting
-// with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellLogService] method instead.
-type CellLogService struct {
- Options []option.RequestOption
-}
-
-// NewCellLogService generates a new service that applies the given options to each
-// request. These options are applied after the parent client's options (if there
-// is one), and before any request-specific options.
-func NewCellLogService(opts ...option.RequestOption) (r *CellLogService) {
- r = &CellLogService{}
- r.Options = opts
- return
-}
-
-func (r *CellLogService) List(ctx context.Context, cellID string, query CellLogListParams, opts ...option.RequestOption) (res *CellLogListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/logs", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-type CellLogListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- Logs []ThreadLog `json:"logs" api:"required"`
- JSON cellLogListResponseJSON `json:"-"`
-}
-
-// cellLogListResponseJSON contains the JSON metadata for the struct
-// [CellLogListResponse]
-type cellLogListResponseJSON struct {
- Cursor apijson.Field
- HasMore apijson.Field
- Logs apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellLogListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellLogListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellLogListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [CellLogListParams]'s query parameters as `url.Values`.
-func (r CellLogListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/celllog_test.go b/celllog_test.go
deleted file mode 100644
index 24c7f68..0000000
--- a/celllog_test.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCellLogListWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Logs.List(
- context.TODO(),
- "cell_abc123",
- cercago.CellLogListParams{
- Cursor: cercago.F("cursor_abc123"),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/cellmetadata.go b/cellmetadata.go
deleted file mode 100644
index 33f8b8c..0000000
--- a/cellmetadata.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellMetadataService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellMetadataService] method instead.
-type CellMetadataService struct {
- Options []option.RequestOption
-}
-
-// NewCellMetadataService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellMetadataService(opts ...option.RequestOption) (r *CellMetadataService) {
- r = &CellMetadataService{}
- r.Options = opts
- return
-}
-
-func (r *CellMetadataService) Update(ctx context.Context, cellID string, body CellMetadataUpdateParams, opts ...option.RequestOption) (res *Cell, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/metadata", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
- return res, err
-}
-
-type CellMetadataUpdateParams struct {
- // Arbitrary string metadata stored on a cell. Runtime enforces maximum key and
- // value sizes.
- Metadata param.Field[CellMetadataParam] `json:"metadata" api:"required"`
-}
-
-func (r CellMetadataUpdateParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
diff --git a/cellsandbox.go b/cellsandbox.go
deleted file mode 100644
index 5e1e37a..0000000
--- a/cellsandbox.go
+++ /dev/null
@@ -1,206 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellSandboxService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellSandboxService] method instead.
-type CellSandboxService struct {
- Options []option.RequestOption
-}
-
-// NewCellSandboxService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellSandboxService(opts ...option.RequestOption) (r *CellSandboxService) {
- r = &CellSandboxService{}
- r.Options = opts
- return
-}
-
-func (r *CellSandboxService) Exec(ctx context.Context, cellID string, body CellSandboxExecParams, opts ...option.RequestOption) (res *SandboxExecResult, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/sandbox/exec", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellSandboxService) Read(ctx context.Context, cellID string, body CellSandboxReadParams, opts ...option.RequestOption) (res *SandboxReadResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/sandbox/read", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellSandboxService) Write(ctx context.Context, cellID string, body CellSandboxWriteParams, opts ...option.RequestOption) (res *CellSandboxWriteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/sandbox/write", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-type SandboxExecResult struct {
- ExitCode float64 `json:"exitCode" api:"required,nullable"`
- Handle string `json:"handle" api:"required"`
- State SandboxExecResultState `json:"state" api:"required"`
- Stderr string `json:"stderr" api:"required"`
- StderrOffset float64 `json:"stderrOffset" api:"required"`
- Stdout string `json:"stdout" api:"required"`
- StdoutOffset float64 `json:"stdoutOffset" api:"required"`
- JSON sandboxExecResultJSON `json:"-"`
-}
-
-// sandboxExecResultJSON contains the JSON metadata for the struct
-// [SandboxExecResult]
-type sandboxExecResultJSON struct {
- ExitCode apijson.Field
- Handle apijson.Field
- State apijson.Field
- Stderr apijson.Field
- StderrOffset apijson.Field
- Stdout apijson.Field
- StdoutOffset apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *SandboxExecResult) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r sandboxExecResultJSON) RawJSON() string {
- return r.raw
-}
-
-type SandboxExecResultState string
-
-const (
- SandboxExecResultStateRunning SandboxExecResultState = "running"
- SandboxExecResultStateExited SandboxExecResultState = "exited"
-)
-
-func (r SandboxExecResultState) IsKnown() bool {
- switch r {
- case SandboxExecResultStateRunning, SandboxExecResultStateExited:
- return true
- }
- return false
-}
-
-type SandboxReadResponse struct {
- BytesRead float64 `json:"bytesRead" api:"required"`
- Content string `json:"content" api:"required"`
- JSON sandboxReadResponseJSON `json:"-"`
-}
-
-// sandboxReadResponseJSON contains the JSON metadata for the struct
-// [SandboxReadResponse]
-type sandboxReadResponseJSON struct {
- BytesRead apijson.Field
- Content apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *SandboxReadResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r sandboxReadResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellSandboxWriteResponse struct {
- Success CellSandboxWriteResponseSuccess `json:"success" api:"required"`
- JSON cellSandboxWriteResponseJSON `json:"-"`
-}
-
-// cellSandboxWriteResponseJSON contains the JSON metadata for the struct
-// [CellSandboxWriteResponse]
-type cellSandboxWriteResponseJSON struct {
- Success apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellSandboxWriteResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellSandboxWriteResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellSandboxWriteResponseSuccess bool
-
-const (
- CellSandboxWriteResponseSuccessTrue CellSandboxWriteResponseSuccess = true
-)
-
-func (r CellSandboxWriteResponseSuccess) IsKnown() bool {
- switch r {
- case CellSandboxWriteResponseSuccessTrue:
- return true
- }
- return false
-}
-
-type CellSandboxExecParams struct {
- Command param.Field[string] `json:"command" api:"required"`
- MaxBuffer param.Field[float64] `json:"maxBuffer"`
- // Timeout in seconds. Runtime converts this to milliseconds.
- Timeout param.Field[float64] `json:"timeout"`
- // Optional sandbox working directory.
- Workdir param.Field[string] `json:"workdir"`
-}
-
-func (r CellSandboxExecParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellSandboxReadParams struct {
- Path param.Field[string] `json:"path" api:"required"`
- Limit param.Field[float64] `json:"limit"`
- Offset param.Field[float64] `json:"offset"`
-}
-
-func (r CellSandboxReadParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellSandboxWriteParams struct {
- Content param.Field[string] `json:"content" api:"required"`
- Path param.Field[string] `json:"path" api:"required"`
-}
-
-func (r CellSandboxWriteParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
diff --git a/cellschedule.go b/cellschedule.go
deleted file mode 100644
index 8074ce7..0000000
--- a/cellschedule.go
+++ /dev/null
@@ -1,304 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellScheduleService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellScheduleService] method instead.
-type CellScheduleService struct {
- Options []option.RequestOption
-}
-
-// NewCellScheduleService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellScheduleService(opts ...option.RequestOption) (r *CellScheduleService) {
- r = &CellScheduleService{}
- r.Options = opts
- return
-}
-
-func (r *CellScheduleService) New(ctx context.Context, cellID string, body CellScheduleNewParams, opts ...option.RequestOption) (res *ScheduledThread, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/schedules", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellScheduleService) Update(ctx context.Context, cellID string, scheduleID string, body CellScheduleUpdateParams, opts ...option.RequestOption) (res *ScheduledThread, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if scheduleID == "" {
- err = errors.New("missing required scheduleId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/schedules/%s", cellID, scheduleID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellScheduleService) List(ctx context.Context, cellID string, opts ...option.RequestOption) (res *CellScheduleListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/schedules", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *CellScheduleService) Delete(ctx context.Context, cellID string, scheduleID string, opts ...option.RequestOption) (res *CellScheduleDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if scheduleID == "" {
- err = errors.New("missing required scheduleId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/schedules/%s", cellID, scheduleID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *CellScheduleService) Trigger(ctx context.Context, cellID string, scheduleID string, opts ...option.RequestOption) (res *CellScheduleTriggerResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if scheduleID == "" {
- err = errors.New("missing required scheduleId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/schedules/%s/trigger", cellID, scheduleID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
- return res, err
-}
-
-type ScheduledThread struct {
- ID string `json:"id" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Cron string `json:"cron" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- Name string `json:"name" api:"required"`
- NextAt string `json:"nextAt" api:"required,nullable"`
- Prompt string `json:"prompt" api:"required"`
- Timezone string `json:"timezone" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Features []ScheduledThreadFeature `json:"features"`
- Instructions string `json:"instructions"`
- Model string `json:"model"`
- JSON scheduledThreadJSON `json:"-"`
-}
-
-// scheduledThreadJSON contains the JSON metadata for the struct [ScheduledThread]
-type scheduledThreadJSON struct {
- ID apijson.Field
- CreatedAt apijson.Field
- Cron apijson.Field
- Enabled apijson.Field
- Name apijson.Field
- NextAt apijson.Field
- Prompt apijson.Field
- Timezone apijson.Field
- UpdatedAt apijson.Field
- Features apijson.Field
- Instructions apijson.Field
- Model apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ScheduledThread) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r scheduledThreadJSON) RawJSON() string {
- return r.raw
-}
-
-type ScheduledThreadFeature string
-
-const (
- ScheduledThreadFeatureMemory ScheduledThreadFeature = "memory"
- ScheduledThreadFeatureSandbox ScheduledThreadFeature = "sandbox"
- ScheduledThreadFeatureWeb ScheduledThreadFeature = "web"
- ScheduledThreadFeatureConnections ScheduledThreadFeature = "connections"
- ScheduledThreadFeatureOAuthConnect ScheduledThreadFeature = "oauth_connect"
-)
-
-func (r ScheduledThreadFeature) IsKnown() bool {
- switch r {
- case ScheduledThreadFeatureMemory, ScheduledThreadFeatureSandbox, ScheduledThreadFeatureWeb, ScheduledThreadFeatureConnections, ScheduledThreadFeatureOAuthConnect:
- return true
- }
- return false
-}
-
-type CellScheduleListResponse struct {
- Schedules []ScheduledThread `json:"schedules" api:"required"`
- JSON cellScheduleListResponseJSON `json:"-"`
-}
-
-// cellScheduleListResponseJSON contains the JSON metadata for the struct
-// [CellScheduleListResponse]
-type cellScheduleListResponseJSON struct {
- Schedules apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellScheduleListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellScheduleListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellScheduleDeleteResponse struct {
- Success CellScheduleDeleteResponseSuccess `json:"success" api:"required"`
- JSON cellScheduleDeleteResponseJSON `json:"-"`
-}
-
-// cellScheduleDeleteResponseJSON contains the JSON metadata for the struct
-// [CellScheduleDeleteResponse]
-type cellScheduleDeleteResponseJSON struct {
- Success apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellScheduleDeleteResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellScheduleDeleteResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellScheduleDeleteResponseSuccess bool
-
-const (
- CellScheduleDeleteResponseSuccessTrue CellScheduleDeleteResponseSuccess = true
-)
-
-func (r CellScheduleDeleteResponseSuccess) IsKnown() bool {
- switch r {
- case CellScheduleDeleteResponseSuccessTrue:
- return true
- }
- return false
-}
-
-type CellScheduleTriggerResponse struct {
- ThreadID string `json:"threadId" api:"required"`
- JSON cellScheduleTriggerResponseJSON `json:"-"`
-}
-
-// cellScheduleTriggerResponseJSON contains the JSON metadata for the struct
-// [CellScheduleTriggerResponse]
-type cellScheduleTriggerResponseJSON struct {
- ThreadID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellScheduleTriggerResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellScheduleTriggerResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellScheduleNewParams struct {
- Cron param.Field[string] `json:"cron" api:"required"`
- Name param.Field[string] `json:"name" api:"required"`
- Prompt param.Field[string] `json:"prompt" api:"required"`
- Features param.Field[[]CellScheduleNewParamsFeature] `json:"features"`
- Instructions param.Field[string] `json:"instructions"`
- Model param.Field[string] `json:"model"`
- Timezone param.Field[string] `json:"timezone"`
-}
-
-func (r CellScheduleNewParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellScheduleNewParamsFeature string
-
-const (
- CellScheduleNewParamsFeatureMemory CellScheduleNewParamsFeature = "memory"
- CellScheduleNewParamsFeatureSandbox CellScheduleNewParamsFeature = "sandbox"
- CellScheduleNewParamsFeatureWeb CellScheduleNewParamsFeature = "web"
- CellScheduleNewParamsFeatureConnections CellScheduleNewParamsFeature = "connections"
- CellScheduleNewParamsFeatureOAuthConnect CellScheduleNewParamsFeature = "oauth_connect"
-)
-
-func (r CellScheduleNewParamsFeature) IsKnown() bool {
- switch r {
- case CellScheduleNewParamsFeatureMemory, CellScheduleNewParamsFeatureSandbox, CellScheduleNewParamsFeatureWeb, CellScheduleNewParamsFeatureConnections, CellScheduleNewParamsFeatureOAuthConnect:
- return true
- }
- return false
-}
-
-type CellScheduleUpdateParams struct {
- Cron param.Field[string] `json:"cron"`
- Enabled param.Field[bool] `json:"enabled"`
- Features param.Field[[]CellScheduleUpdateParamsFeature] `json:"features"`
- Instructions param.Field[string] `json:"instructions"`
- Model param.Field[string] `json:"model"`
- Name param.Field[string] `json:"name"`
- Prompt param.Field[string] `json:"prompt"`
- Timezone param.Field[string] `json:"timezone"`
-}
-
-func (r CellScheduleUpdateParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellScheduleUpdateParamsFeature string
-
-const (
- CellScheduleUpdateParamsFeatureMemory CellScheduleUpdateParamsFeature = "memory"
- CellScheduleUpdateParamsFeatureSandbox CellScheduleUpdateParamsFeature = "sandbox"
- CellScheduleUpdateParamsFeatureWeb CellScheduleUpdateParamsFeature = "web"
- CellScheduleUpdateParamsFeatureConnections CellScheduleUpdateParamsFeature = "connections"
- CellScheduleUpdateParamsFeatureOAuthConnect CellScheduleUpdateParamsFeature = "oauth_connect"
-)
-
-func (r CellScheduleUpdateParamsFeature) IsKnown() bool {
- switch r {
- case CellScheduleUpdateParamsFeatureMemory, CellScheduleUpdateParamsFeatureSandbox, CellScheduleUpdateParamsFeatureWeb, CellScheduleUpdateParamsFeatureConnections, CellScheduleUpdateParamsFeatureOAuthConnect:
- return true
- }
- return false
-}
diff --git a/cellthread.go b/cellthread.go
deleted file mode 100644
index 0508fe6..0000000
--- a/cellthread.go
+++ /dev/null
@@ -1,735 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellThreadService contains methods and other services that help with interacting
-// with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellThreadService] method instead.
-type CellThreadService struct {
- Options []option.RequestOption
- Approvals *CellThreadApprovalService
- ApprovalGrants *CellThreadApprovalGrantService
- Logs *CellThreadLogService
- Events *CellThreadEventService
-}
-
-// NewCellThreadService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellThreadService(opts ...option.RequestOption) (r *CellThreadService) {
- r = &CellThreadService{}
- r.Options = opts
- r.Approvals = NewCellThreadApprovalService(opts...)
- r.ApprovalGrants = NewCellThreadApprovalGrantService(opts...)
- r.Logs = NewCellThreadLogService(opts...)
- r.Events = NewCellThreadEventService(opts...)
- return
-}
-
-func (r *CellThreadService) New(ctx context.Context, cellID string, body CellThreadNewParams, opts ...option.RequestOption) (res *Thread, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellThreadService) Get(ctx context.Context, cellID string, threadID string, query CellThreadGetParams, opts ...option.RequestOption) (res *Thread, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-func (r *CellThreadService) List(ctx context.Context, cellID string, query CellThreadListParams, opts ...option.RequestOption) (res *CellThreadListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// Cancel a running or awaiting thread. The underlying runtime treats repeat
-// cancellation as an idempotent lifecycle operation when possible.
-func (r *CellThreadService) Cancel(ctx context.Context, cellID string, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/cancel", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
- return res, err
-}
-
-// Close an idle thread. Closing a running, awaiting, or already-closed thread
-// returns a lifecycle conflict.
-func (r *CellThreadService) Close(ctx context.Context, cellID string, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/close", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
- return res, err
-}
-
-// Force context compaction for an idle thread. Compacting a running thread returns
-// a lifecycle conflict.
-func (r *CellThreadService) Compact(ctx context.Context, cellID string, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/compact", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
- return res, err
-}
-
-// Steer a thread with another user message. Steering a closed thread returns a
-// conflict; steering a running or awaiting thread queues the message.
-func (r *CellThreadService) Steer(ctx context.Context, cellID string, threadID string, body CellThreadSteerParams, opts ...option.RequestOption) (res *SteerResult, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/steer", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *CellThreadService) Turn(ctx context.Context, cellID string, threadID string, body CellThreadTurnParams, opts ...option.RequestOption) (res *Turn, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/turns", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-type ContentBlock = interface{}
-
-type PendingSubThread struct {
- SubThreadID string `json:"subThreadId" api:"required"`
- ToolUseID string `json:"toolUseId" api:"required"`
- JSON pendingSubThreadJSON `json:"-"`
-}
-
-// pendingSubThreadJSON contains the JSON metadata for the struct
-// [PendingSubThread]
-type pendingSubThreadJSON struct {
- SubThreadID apijson.Field
- ToolUseID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *PendingSubThread) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r pendingSubThreadJSON) RawJSON() string {
- return r.raw
-}
-
-type SteerResult struct {
- Status SteerResultStatus `json:"status" api:"required"`
- // `idle` threads can accept a new turn or be closed. `running` threads have an
- // active turn. `awaiting` threads are paused on external input such as approvals.
- // `closed` threads are terminal.
- ThreadStatus ThreadStatus `json:"threadStatus" api:"required"`
- TurnID string `json:"turnId" api:"required"`
- JSON steerResultJSON `json:"-"`
-}
-
-// steerResultJSON contains the JSON metadata for the struct [SteerResult]
-type steerResultJSON struct {
- Status apijson.Field
- ThreadStatus apijson.Field
- TurnID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *SteerResult) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r steerResultJSON) RawJSON() string {
- return r.raw
-}
-
-type SteerResultStatus string
-
-const (
- SteerResultStatusEnqueued SteerResultStatus = "enqueued"
- SteerResultStatusTurnStarted SteerResultStatus = "turn_started"
-)
-
-func (r SteerResultStatus) IsKnown() bool {
- switch r {
- case SteerResultStatusEnqueued, SteerResultStatusTurnStarted:
- return true
- }
- return false
-}
-
-type Thread struct {
- ID string `json:"id" api:"required"`
- CellID string `json:"cellId" api:"required"`
- CompactionSummary string `json:"compactionSummary" api:"required,nullable"`
- CompactionThroughSeq float64 `json:"compactionThroughSeq" api:"required,nullable"`
- CompiledContext ThreadCompiledContext `json:"compiledContext" api:"required,nullable"`
- CompletedAt string `json:"completedAt" api:"required,nullable"`
- ComposedSystemPrompt string `json:"composedSystemPrompt" api:"required,nullable"`
- ContextWindow ThreadContextWindow `json:"contextWindow" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Depth float64 `json:"depth" api:"required"`
- Error string `json:"error" api:"required,nullable"`
- Instructions string `json:"instructions" api:"required,nullable"`
- LastTurnStatus ThreadLastTurnStatus `json:"lastTurnStatus" api:"required,nullable"`
- Messages []ThreadMessage `json:"messages" api:"required"`
- Model string `json:"model" api:"required"`
- ParentThreadID string `json:"parentThreadId" api:"required,nullable"`
- PendingSubThreads []PendingSubThread `json:"pendingSubThreads" api:"required"`
- Result string `json:"result" api:"required,nullable"`
- ScheduleID string `json:"scheduleId" api:"required,nullable"`
- ScheduleSeq float64 `json:"scheduleSeq" api:"required,nullable"`
- // `idle` threads can accept a new turn or be closed. `running` threads have an
- // active turn. `awaiting` threads are paused on external input such as approvals.
- // `closed` threads are terminal.
- Status ThreadStatus `json:"status" api:"required"`
- SubThreads []ThreadSummary `json:"subThreads" api:"required"`
- Tools []RuntimeToolName `json:"tools" api:"required"`
- Turns []Turn `json:"turns" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- UserMessage string `json:"userMessage" api:"required"`
- JSON threadJSON `json:"-"`
-}
-
-// threadJSON contains the JSON metadata for the struct [Thread]
-type threadJSON struct {
- ID apijson.Field
- CellID apijson.Field
- CompactionSummary apijson.Field
- CompactionThroughSeq apijson.Field
- CompiledContext apijson.Field
- CompletedAt apijson.Field
- ComposedSystemPrompt apijson.Field
- ContextWindow apijson.Field
- CreatedAt apijson.Field
- Depth apijson.Field
- Error apijson.Field
- Instructions apijson.Field
- LastTurnStatus apijson.Field
- Messages apijson.Field
- Model apijson.Field
- ParentThreadID apijson.Field
- PendingSubThreads apijson.Field
- Result apijson.Field
- ScheduleID apijson.Field
- ScheduleSeq apijson.Field
- Status apijson.Field
- SubThreads apijson.Field
- Tools apijson.Field
- Turns apijson.Field
- UpdatedAt apijson.Field
- UserMessage apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *Thread) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r threadJSON) RawJSON() string {
- return r.raw
-}
-
-type ThreadLastTurnStatus string
-
-const (
- ThreadLastTurnStatusCompleted ThreadLastTurnStatus = "completed"
- ThreadLastTurnStatusFailed ThreadLastTurnStatus = "failed"
-)
-
-func (r ThreadLastTurnStatus) IsKnown() bool {
- switch r {
- case ThreadLastTurnStatusCompleted, ThreadLastTurnStatusFailed:
- return true
- }
- return false
-}
-
-type ThreadCompiledContext struct {
- EnabledTools []RuntimeToolName `json:"enabledTools" api:"required,nullable"`
- SystemPrompt string `json:"systemPrompt" api:"required,nullable"`
- TurnID string `json:"turnId" api:"required,nullable"`
- JSON threadCompiledContextJSON `json:"-"`
-}
-
-// threadCompiledContextJSON contains the JSON metadata for the struct
-// [ThreadCompiledContext]
-type threadCompiledContextJSON struct {
- EnabledTools apijson.Field
- SystemPrompt apijson.Field
- TurnID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ThreadCompiledContext) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r threadCompiledContextJSON) RawJSON() string {
- return r.raw
-}
-
-type ThreadContextWindow struct {
- Compacted bool `json:"compacted" api:"required"`
- CompactionThroughSeq float64 `json:"compactionThroughSeq" api:"required,nullable"`
- ContextWindowTokens float64 `json:"contextWindowTokens" api:"required"`
- EstimationMethod ThreadContextWindowEstimationMethod `json:"estimationMethod" api:"required"`
- LlmEstimatedTokens float64 `json:"llmEstimatedTokens" api:"required"`
- Model string `json:"model" api:"required"`
- RawEstimatedTokens float64 `json:"rawEstimatedTokens" api:"required"`
- JSON threadContextWindowJSON `json:"-"`
-}
-
-// threadContextWindowJSON contains the JSON metadata for the struct
-// [ThreadContextWindow]
-type threadContextWindowJSON struct {
- Compacted apijson.Field
- CompactionThroughSeq apijson.Field
- ContextWindowTokens apijson.Field
- EstimationMethod apijson.Field
- LlmEstimatedTokens apijson.Field
- Model apijson.Field
- RawEstimatedTokens apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ThreadContextWindow) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r threadContextWindowJSON) RawJSON() string {
- return r.raw
-}
-
-type ThreadContextWindowEstimationMethod string
-
-const (
- ThreadContextWindowEstimationMethodHeuristicRequestV1 ThreadContextWindowEstimationMethod = "heuristic_request_v1"
-)
-
-func (r ThreadContextWindowEstimationMethod) IsKnown() bool {
- switch r {
- case ThreadContextWindowEstimationMethodHeuristicRequestV1:
- return true
- }
- return false
-}
-
-type ThreadMessage struct {
- Content []ContentBlock `json:"content" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Role ThreadMessageRole `json:"role" api:"required"`
- Seq float64 `json:"seq" api:"required"`
- JSON threadMessageJSON `json:"-"`
-}
-
-// threadMessageJSON contains the JSON metadata for the struct [ThreadMessage]
-type threadMessageJSON struct {
- Content apijson.Field
- CreatedAt apijson.Field
- Role apijson.Field
- Seq apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ThreadMessage) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r threadMessageJSON) RawJSON() string {
- return r.raw
-}
-
-type ThreadMessageRole string
-
-const (
- ThreadMessageRoleUser ThreadMessageRole = "user"
- ThreadMessageRoleAssistant ThreadMessageRole = "assistant"
-)
-
-func (r ThreadMessageRole) IsKnown() bool {
- switch r {
- case ThreadMessageRoleUser, ThreadMessageRoleAssistant:
- return true
- }
- return false
-}
-
-// `idle` threads can accept a new turn or be closed. `running` threads have an
-// active turn. `awaiting` threads are paused on external input such as approvals.
-// `closed` threads are terminal.
-type ThreadStatus string
-
-const (
- ThreadStatusIdle ThreadStatus = "idle"
- ThreadStatusRunning ThreadStatus = "running"
- ThreadStatusAwaiting ThreadStatus = "awaiting"
- ThreadStatusClosed ThreadStatus = "closed"
-)
-
-func (r ThreadStatus) IsKnown() bool {
- switch r {
- case ThreadStatusIdle, ThreadStatusRunning, ThreadStatusAwaiting, ThreadStatusClosed:
- return true
- }
- return false
-}
-
-type ThreadSummary struct {
- ID string `json:"id" api:"required"`
- CompletedAt string `json:"completedAt" api:"required,nullable"`
- CreatedAt string `json:"createdAt" api:"required"`
- MessageCount float64 `json:"messageCount" api:"required"`
- Model string `json:"model" api:"required"`
- ParentThreadID string `json:"parentThreadId" api:"required,nullable"`
- Result string `json:"result" api:"required,nullable"`
- ScheduleID string `json:"scheduleId" api:"required,nullable"`
- ScheduleSeq float64 `json:"scheduleSeq" api:"required,nullable"`
- // `idle` threads can accept a new turn or be closed. `running` threads have an
- // active turn. `awaiting` threads are paused on external input such as approvals.
- // `closed` threads are terminal.
- Status ThreadStatus `json:"status" api:"required"`
- StepCount float64 `json:"stepCount" api:"required"`
- JSON threadSummaryJSON `json:"-"`
-}
-
-// threadSummaryJSON contains the JSON metadata for the struct [ThreadSummary]
-type threadSummaryJSON struct {
- ID apijson.Field
- CompletedAt apijson.Field
- CreatedAt apijson.Field
- MessageCount apijson.Field
- Model apijson.Field
- ParentThreadID apijson.Field
- Result apijson.Field
- ScheduleID apijson.Field
- ScheduleSeq apijson.Field
- Status apijson.Field
- StepCount apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ThreadSummary) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r threadSummaryJSON) RawJSON() string {
- return r.raw
-}
-
-type TokenUsage struct {
- InputTokens float64 `json:"inputTokens" api:"required"`
- OutputTokens float64 `json:"outputTokens" api:"required"`
- JSON tokenUsageJSON `json:"-"`
-}
-
-// tokenUsageJSON contains the JSON metadata for the struct [TokenUsage]
-type tokenUsageJSON struct {
- InputTokens apijson.Field
- OutputTokens apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *TokenUsage) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r tokenUsageJSON) RawJSON() string {
- return r.raw
-}
-
-type Turn struct {
- ID string `json:"id" api:"required"`
- CompletedAt string `json:"completedAt" api:"required,nullable"`
- EndMessageSeq float64 `json:"endMessageSeq" api:"required,nullable"`
- Error string `json:"error" api:"required,nullable"`
- Result string `json:"result" api:"required,nullable"`
- Seq float64 `json:"seq" api:"required"`
- StartedAt string `json:"startedAt" api:"required"`
- StartMessageSeq float64 `json:"startMessageSeq" api:"required"`
- Status TurnStatus `json:"status" api:"required"`
- ThreadID string `json:"threadId" api:"required"`
- TokenUsage TokenUsage `json:"tokenUsage" api:"required,nullable"`
- UserMessage string `json:"userMessage" api:"required"`
- JSON turnJSON `json:"-"`
-}
-
-// turnJSON contains the JSON metadata for the struct [Turn]
-type turnJSON struct {
- ID apijson.Field
- CompletedAt apijson.Field
- EndMessageSeq apijson.Field
- Error apijson.Field
- Result apijson.Field
- Seq apijson.Field
- StartedAt apijson.Field
- StartMessageSeq apijson.Field
- Status apijson.Field
- ThreadID apijson.Field
- TokenUsage apijson.Field
- UserMessage apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *Turn) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r turnJSON) RawJSON() string {
- return r.raw
-}
-
-type TurnStatus string
-
-const (
- TurnStatusRunning TurnStatus = "running"
- TurnStatusCompleted TurnStatus = "completed"
- TurnStatusFailed TurnStatus = "failed"
-)
-
-func (r TurnStatus) IsKnown() bool {
- switch r {
- case TurnStatusRunning, TurnStatusCompleted, TurnStatusFailed:
- return true
- }
- return false
-}
-
-type CellThreadListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- Threads []ThreadSummary `json:"threads" api:"required"`
- JSON cellThreadListResponseJSON `json:"-"`
-}
-
-// cellThreadListResponseJSON contains the JSON metadata for the struct
-// [CellThreadListResponse]
-type cellThreadListResponseJSON struct {
- Cursor apijson.Field
- HasMore apijson.Field
- Threads apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellThreadListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellThreadListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellThreadNewParams struct {
- Features param.Field[[]CellThreadNewParamsFeature] `json:"features"`
- Instructions param.Field[string] `json:"instructions"`
- Model param.Field[string] `json:"model"`
- // Deprecated alias for `instructions`; accepted for backwards compatibility.
- SystemPrompt param.Field[string] `json:"systemPrompt"`
- UserMessage param.Field[string] `json:"userMessage"`
-}
-
-func (r CellThreadNewParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellThreadNewParamsFeature string
-
-const (
- CellThreadNewParamsFeatureMemory CellThreadNewParamsFeature = "memory"
- CellThreadNewParamsFeatureSandbox CellThreadNewParamsFeature = "sandbox"
- CellThreadNewParamsFeatureWeb CellThreadNewParamsFeature = "web"
- CellThreadNewParamsFeatureConnections CellThreadNewParamsFeature = "connections"
- CellThreadNewParamsFeatureOAuthConnect CellThreadNewParamsFeature = "oauth_connect"
-)
-
-func (r CellThreadNewParamsFeature) IsKnown() bool {
- switch r {
- case CellThreadNewParamsFeatureMemory, CellThreadNewParamsFeatureSandbox, CellThreadNewParamsFeatureWeb, CellThreadNewParamsFeatureConnections, CellThreadNewParamsFeatureOAuthConnect:
- return true
- }
- return false
-}
-
-type CellThreadGetParams struct {
- // When true, includes debug-only compiled context fields.
- Debug param.Field[CellThreadGetParamsDebug] `query:"debug"`
- // When true, includes message content in the thread detail.
- IncludeMessages param.Field[CellThreadGetParamsIncludeMessages] `query:"includeMessages"`
-}
-
-// URLQuery serializes [CellThreadGetParams]'s query parameters as `url.Values`.
-func (r CellThreadGetParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-// When true, includes debug-only compiled context fields.
-type CellThreadGetParamsDebug string
-
-const (
- CellThreadGetParamsDebugTrue CellThreadGetParamsDebug = "true"
- CellThreadGetParamsDebugFalse CellThreadGetParamsDebug = "false"
-)
-
-func (r CellThreadGetParamsDebug) IsKnown() bool {
- switch r {
- case CellThreadGetParamsDebugTrue, CellThreadGetParamsDebugFalse:
- return true
- }
- return false
-}
-
-// When true, includes message content in the thread detail.
-type CellThreadGetParamsIncludeMessages string
-
-const (
- CellThreadGetParamsIncludeMessagesTrue CellThreadGetParamsIncludeMessages = "true"
- CellThreadGetParamsIncludeMessagesFalse CellThreadGetParamsIncludeMessages = "false"
-)
-
-func (r CellThreadGetParamsIncludeMessages) IsKnown() bool {
- switch r {
- case CellThreadGetParamsIncludeMessagesTrue, CellThreadGetParamsIncludeMessagesFalse:
- return true
- }
- return false
-}
-
-type CellThreadListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
- // Optional schedule id filter.
- ScheduleID param.Field[string] `query:"scheduleId"`
- // Optional thread status filter.
- Status param.Field[ThreadStatus] `query:"status"`
-}
-
-// URLQuery serializes [CellThreadListParams]'s query parameters as `url.Values`.
-func (r CellThreadListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type CellThreadSteerParams struct {
- Message param.Field[string] `json:"message" api:"required"`
-}
-
-func (r CellThreadSteerParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellThreadTurnParams struct {
- UserMessage param.Field[string] `json:"userMessage" api:"required"`
- Features param.Field[[]CellThreadTurnParamsFeature] `json:"features"`
- Model param.Field[string] `json:"model"`
-}
-
-func (r CellThreadTurnParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellThreadTurnParamsFeature string
-
-const (
- CellThreadTurnParamsFeatureMemory CellThreadTurnParamsFeature = "memory"
- CellThreadTurnParamsFeatureSandbox CellThreadTurnParamsFeature = "sandbox"
- CellThreadTurnParamsFeatureWeb CellThreadTurnParamsFeature = "web"
- CellThreadTurnParamsFeatureConnections CellThreadTurnParamsFeature = "connections"
- CellThreadTurnParamsFeatureOAuthConnect CellThreadTurnParamsFeature = "oauth_connect"
-)
-
-func (r CellThreadTurnParamsFeature) IsKnown() bool {
- switch r {
- case CellThreadTurnParamsFeatureMemory, CellThreadTurnParamsFeatureSandbox, CellThreadTurnParamsFeatureWeb, CellThreadTurnParamsFeatureConnections, CellThreadTurnParamsFeatureOAuthConnect:
- return true
- }
- return false
-}
diff --git a/cellthreadapproval.go b/cellthreadapproval.go
deleted file mode 100644
index f24bdad..0000000
--- a/cellthreadapproval.go
+++ /dev/null
@@ -1,94 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellThreadApprovalService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellThreadApprovalService] method instead.
-type CellThreadApprovalService struct {
- Options []option.RequestOption
-}
-
-// NewCellThreadApprovalService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewCellThreadApprovalService(opts ...option.RequestOption) (r *CellThreadApprovalService) {
- r = &CellThreadApprovalService{}
- r.Options = opts
- return
-}
-
-func (r *CellThreadApprovalService) Resolve(ctx context.Context, cellID string, threadID string, approvalID string, body CellThreadApprovalResolveParams, opts ...option.RequestOption) (res *ApprovalRequest, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- if approvalID == "" {
- err = errors.New("missing required approvalId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/approvals/%s", cellID, threadID, approvalID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-type CellThreadApprovalResolveParams struct {
- Decision param.Field[CellThreadApprovalResolveParamsDecision] `json:"decision" api:"required"`
- Grant param.Field[CellThreadApprovalResolveParamsGrant] `json:"grant"`
-}
-
-func (r CellThreadApprovalResolveParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type CellThreadApprovalResolveParamsDecision string
-
-const (
- CellThreadApprovalResolveParamsDecisionApprove CellThreadApprovalResolveParamsDecision = "approve"
- CellThreadApprovalResolveParamsDecisionDeny CellThreadApprovalResolveParamsDecision = "deny"
- CellThreadApprovalResolveParamsDecisionCancel CellThreadApprovalResolveParamsDecision = "cancel"
-)
-
-func (r CellThreadApprovalResolveParamsDecision) IsKnown() bool {
- switch r {
- case CellThreadApprovalResolveParamsDecisionApprove, CellThreadApprovalResolveParamsDecisionDeny, CellThreadApprovalResolveParamsDecisionCancel:
- return true
- }
- return false
-}
-
-type CellThreadApprovalResolveParamsGrant string
-
-const (
- CellThreadApprovalResolveParamsGrantThread CellThreadApprovalResolveParamsGrant = "thread"
- CellThreadApprovalResolveParamsGrantCell CellThreadApprovalResolveParamsGrant = "cell"
-)
-
-func (r CellThreadApprovalResolveParamsGrant) IsKnown() bool {
- switch r {
- case CellThreadApprovalResolveParamsGrantThread, CellThreadApprovalResolveParamsGrantCell:
- return true
- }
- return false
-}
diff --git a/cellthreadapproval_test.go b/cellthreadapproval_test.go
deleted file mode 100644
index 681a145..0000000
--- a/cellthreadapproval_test.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCellThreadApprovalResolveWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Threads.Approvals.Resolve(
- context.TODO(),
- "cell_abc123",
- "thread_abc123",
- "approval_abc123",
- cercago.CellThreadApprovalResolveParams{
- Decision: cercago.F(cercago.CellThreadApprovalResolveParamsDecisionApprove),
- Grant: cercago.F(cercago.CellThreadApprovalResolveParamsGrantThread),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/cellthreadapprovalgrant.go b/cellthreadapprovalgrant.go
deleted file mode 100644
index 11d92ce..0000000
--- a/cellthreadapprovalgrant.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellThreadApprovalGrantService contains methods and other services that help
-// with interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellThreadApprovalGrantService] method instead.
-type CellThreadApprovalGrantService struct {
- Options []option.RequestOption
-}
-
-// NewCellThreadApprovalGrantService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewCellThreadApprovalGrantService(opts ...option.RequestOption) (r *CellThreadApprovalGrantService) {
- r = &CellThreadApprovalGrantService{}
- r.Options = opts
- return
-}
-
-func (r *CellThreadApprovalGrantService) List(ctx context.Context, cellID string, threadID string, opts ...option.RequestOption) (res *[]ApprovalGrant, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/approval-grants", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *CellThreadApprovalGrantService) Delete(ctx context.Context, cellID string, threadID string, grantID string, opts ...option.RequestOption) (res *CellThreadApprovalGrantDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- if grantID == "" {
- err = errors.New("missing required grantId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/approval-grants/%s", cellID, threadID, grantID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
- return res, err
-}
-
-type CellThreadApprovalGrantDeleteResponse struct {
- Ok CellThreadApprovalGrantDeleteResponseOk `json:"ok" api:"required"`
- JSON cellThreadApprovalGrantDeleteResponseJSON `json:"-"`
-}
-
-// cellThreadApprovalGrantDeleteResponseJSON contains the JSON metadata for the
-// struct [CellThreadApprovalGrantDeleteResponse]
-type cellThreadApprovalGrantDeleteResponseJSON struct {
- Ok apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellThreadApprovalGrantDeleteResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellThreadApprovalGrantDeleteResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellThreadApprovalGrantDeleteResponseOk bool
-
-const (
- CellThreadApprovalGrantDeleteResponseOkTrue CellThreadApprovalGrantDeleteResponseOk = true
-)
-
-func (r CellThreadApprovalGrantDeleteResponseOk) IsKnown() bool {
- switch r {
- case CellThreadApprovalGrantDeleteResponseOkTrue:
- return true
- }
- return false
-}
diff --git a/cellthreadapprovalgrant_test.go b/cellthreadapprovalgrant_test.go
deleted file mode 100644
index be3fb97..0000000
--- a/cellthreadapprovalgrant_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCellThreadApprovalGrantList(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Threads.ApprovalGrants.List(
- context.TODO(),
- "cell_abc123",
- "thread_abc123",
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestCellThreadApprovalGrantDelete(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Threads.ApprovalGrants.Delete(
- context.TODO(),
- "cell_abc123",
- "thread_abc123",
- "grant_abc123",
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/cellthreadevent.go b/cellthreadevent.go
deleted file mode 100644
index 7a44c36..0000000
--- a/cellthreadevent.go
+++ /dev/null
@@ -1,155 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellThreadEventService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellThreadEventService] method instead.
-type CellThreadEventService struct {
- Options []option.RequestOption
-}
-
-// NewCellThreadEventService generates a new service that applies the given options
-// to each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellThreadEventService(opts ...option.RequestOption) (r *CellThreadEventService) {
- r = &CellThreadEventService{}
- r.Options = opts
- return
-}
-
-func (r *CellThreadEventService) List(ctx context.Context, cellID string, threadID string, query CellThreadEventListParams, opts ...option.RequestOption) (res *CellThreadEventListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/events", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// WebSocket upgrade endpoint. Set
-// `Sec-WebSocket-Protocol: cell-v1, cell-auth-` so the runtime can
-// authenticate the stream while preserving the public subprotocol. HTTP clients
-// that cannot upgrade should use `/cells/{cellId}/threads/{threadId}/events` as
-// the polling analog.
-func (r *CellThreadEventService) Subscribe(ctx context.Context, cellID string, threadID string, opts ...option.RequestOption) (res *CellThreadEventSubscribeResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/events/subscribe", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-type CellThreadEventListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- Events []SubscriptionEvent `json:"events" api:"required"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON cellThreadEventListResponseJSON `json:"-"`
-}
-
-// cellThreadEventListResponseJSON contains the JSON metadata for the struct
-// [CellThreadEventListResponse]
-type cellThreadEventListResponseJSON struct {
- Cursor apijson.Field
- Events apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellThreadEventListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellThreadEventListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellThreadEventSubscribeResponse struct {
- Error string `json:"error" api:"required"`
- JSON cellThreadEventSubscribeResponseJSON `json:"-"`
-}
-
-// cellThreadEventSubscribeResponseJSON contains the JSON metadata for the struct
-// [CellThreadEventSubscribeResponse]
-type cellThreadEventSubscribeResponseJSON struct {
- Error apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellThreadEventSubscribeResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellThreadEventSubscribeResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellThreadEventListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Comma-separated event type filter.
- Events param.Field[string] `query:"events"`
- // When true, starts from the beginning of the retained buffer.
- History param.Field[CellThreadEventListParamsHistory] `query:"history"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [CellThreadEventListParams]'s query parameters as
-// `url.Values`.
-func (r CellThreadEventListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-// When true, starts from the beginning of the retained buffer.
-type CellThreadEventListParamsHistory string
-
-const (
- CellThreadEventListParamsHistoryTrue CellThreadEventListParamsHistory = "true"
- CellThreadEventListParamsHistoryFalse CellThreadEventListParamsHistory = "false"
-)
-
-func (r CellThreadEventListParamsHistory) IsKnown() bool {
- switch r {
- case CellThreadEventListParamsHistoryTrue, CellThreadEventListParamsHistoryFalse:
- return true
- }
- return false
-}
diff --git a/cellthreadlog.go b/cellthreadlog.go
deleted file mode 100644
index 7b9b6d4..0000000
--- a/cellthreadlog.go
+++ /dev/null
@@ -1,149 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellThreadLogService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellThreadLogService] method instead.
-type CellThreadLogService struct {
- Options []option.RequestOption
-}
-
-// NewCellThreadLogService generates a new service that applies the given options
-// to each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellThreadLogService(opts ...option.RequestOption) (r *CellThreadLogService) {
- r = &CellThreadLogService{}
- r.Options = opts
- return
-}
-
-func (r *CellThreadLogService) List(ctx context.Context, cellID string, threadID string, query CellThreadLogListParams, opts ...option.RequestOption) (res *CellThreadLogListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/threads/%s/logs", cellID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-type ThreadLog struct {
- ID string `json:"id" api:"required"`
- Activity string `json:"activity" api:"required,nullable"`
- CreatedAt string `json:"createdAt" api:"required"`
- InputTokens float64 `json:"inputTokens" api:"required"`
- MessageCount float64 `json:"messageCount" api:"required"`
- NextStep string `json:"nextStep" api:"required,nullable"`
- OutputTokens float64 `json:"outputTokens" api:"required"`
- Status ThreadLogStatus `json:"status" api:"required"`
- ThreadID string `json:"threadId" api:"required"`
- TurnCompletedAt string `json:"turnCompletedAt" api:"required"`
- TurnSeq float64 `json:"turnSeq" api:"required"`
- JSON threadLogJSON `json:"-"`
-}
-
-// threadLogJSON contains the JSON metadata for the struct [ThreadLog]
-type threadLogJSON struct {
- ID apijson.Field
- Activity apijson.Field
- CreatedAt apijson.Field
- InputTokens apijson.Field
- MessageCount apijson.Field
- NextStep apijson.Field
- OutputTokens apijson.Field
- Status apijson.Field
- ThreadID apijson.Field
- TurnCompletedAt apijson.Field
- TurnSeq apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ThreadLog) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r threadLogJSON) RawJSON() string {
- return r.raw
-}
-
-type ThreadLogStatus string
-
-const (
- ThreadLogStatusCompleted ThreadLogStatus = "completed"
- ThreadLogStatusFailed ThreadLogStatus = "failed"
-)
-
-func (r ThreadLogStatus) IsKnown() bool {
- switch r {
- case ThreadLogStatusCompleted, ThreadLogStatusFailed:
- return true
- }
- return false
-}
-
-type CellThreadLogListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- Logs []ThreadLog `json:"logs" api:"required"`
- JSON cellThreadLogListResponseJSON `json:"-"`
-}
-
-// cellThreadLogListResponseJSON contains the JSON metadata for the struct
-// [CellThreadLogListResponse]
-type cellThreadLogListResponseJSON struct {
- Cursor apijson.Field
- HasMore apijson.Field
- Logs apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellThreadLogListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellThreadLogListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CellThreadLogListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [CellThreadLogListParams]'s query parameters as
-// `url.Values`.
-func (r CellThreadLogListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/cellthreadlog_test.go b/cellthreadlog_test.go
deleted file mode 100644
index 030d5dd..0000000
--- a/cellthreadlog_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCellThreadLogListWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Threads.Logs.List(
- context.TODO(),
- "cell_abc123",
- "thread_abc123",
- cercago.CellThreadLogListParams{
- Cursor: cercago.F("cursor_abc123"),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/celltool_test.go b/celltool_test.go
deleted file mode 100644
index aff5aa6..0000000
--- a/celltool_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCellToolList(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Cells.Tools.List(context.TODO(), "cell_abc123")
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/celltoolsource.go b/celltoolsource.go
deleted file mode 100644
index 3f9ccd2..0000000
--- a/celltoolsource.go
+++ /dev/null
@@ -1,70 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// CellToolSourceService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellToolSourceService] method instead.
-type CellToolSourceService struct {
- Options []option.RequestOption
-}
-
-// NewCellToolSourceService generates a new service that applies the given options
-// to each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellToolSourceService(opts ...option.RequestOption) (r *CellToolSourceService) {
- r = &CellToolSourceService{}
- r.Options = opts
- return
-}
-
-func (r *CellToolSourceService) List(ctx context.Context, cellID string, opts ...option.RequestOption) (res *CellToolSourceListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
- return nil, err
- }
- path := fmt.Sprintf("cells/%s/tool-sources", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-type CellToolSourceListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- Sources []ToolSource `json:"sources" api:"required"`
- JSON cellToolSourceListResponseJSON `json:"-"`
-}
-
-// cellToolSourceListResponseJSON contains the JSON metadata for the struct
-// [CellToolSourceListResponse]
-type cellToolSourceListResponseJSON struct {
- Cursor apijson.Field
- HasMore apijson.Field
- Sources apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellToolSourceListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellToolSourceListResponseJSON) RawJSON() string {
- return r.raw
-}
diff --git a/client.go b/client.go
index f226d38..3eb19fc 100644
--- a/client.go
+++ b/client.go
@@ -16,13 +16,25 @@ import (
// interacting with the cerca API. You should not instantiate this client directly,
// and instead use the [NewClient] method instead.
type Client struct {
- Options []option.RequestOption
- Auth *AuthService
- OAuth *OAuthService
- Credentials *CredentialService
- Environments *EnvironmentService
- Cells *CellService
- Models *ModelService
+ Options []option.RequestOption
+ Auth *AuthService
+ OAuth *OAuthService
+ Credentials *CredentialService
+ Fleets *FleetService
+ ToolSources *ToolSourceService
+ Webhooks *WebhookService
+ Events *EventService
+ Agents *AgentService
+ Threads *ThreadService
+ Context *ContextService
+ Connections *ConnectionService
+ Schedules *ScheduleService
+ Approvals *ApprovalService
+ ApprovalGrants *ApprovalGrantService
+ Logs *LogService
+ Sandbox *SandboxService
+ Tools *ToolService
+ Models *ModelService
}
// DefaultClientOptions read from the environment (CERCA_API_KEY, CERCA_BASE_URL).
@@ -50,8 +62,20 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
r.Auth = NewAuthService(opts...)
r.OAuth = NewOAuthService(opts...)
r.Credentials = NewCredentialService(opts...)
- r.Environments = NewEnvironmentService(opts...)
- r.Cells = NewCellService(opts...)
+ r.Fleets = NewFleetService(opts...)
+ r.ToolSources = NewToolSourceService(opts...)
+ r.Webhooks = NewWebhookService(opts...)
+ r.Events = NewEventService(opts...)
+ r.Agents = NewAgentService(opts...)
+ r.Threads = NewThreadService(opts...)
+ r.Context = NewContextService(opts...)
+ r.Connections = NewConnectionService(opts...)
+ r.Schedules = NewScheduleService(opts...)
+ r.Approvals = NewApprovalService(opts...)
+ r.ApprovalGrants = NewApprovalGrantService(opts...)
+ r.Logs = NewLogService(opts...)
+ r.Sandbox = NewSandboxService(opts...)
+ r.Tools = NewToolService(opts...)
r.Models = NewModelService(opts...)
return
diff --git a/client_test.go b/client_test.go
index 959e5cf..63587e8 100644
--- a/client_test.go
+++ b/client_test.go
@@ -38,7 +38,7 @@ func TestUserAgentHeader(t *testing.T) {
},
}),
)
- _, _ = client.Cells.New(context.Background(), cercago.CellNewParams{
+ _, _ = client.Agents.New(context.Background(), cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if userAgent != fmt.Sprintf("Cerca/Go %s", internal.PackageVersion) {
@@ -64,7 +64,7 @@ func TestRetryAfter(t *testing.T) {
},
}),
)
- _, err := client.Cells.New(context.Background(), cercago.CellNewParams{
+ _, err := client.Agents.New(context.Background(), cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if err == nil {
@@ -101,7 +101,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
}),
option.WithHeaderDel("X-Stainless-Retry-Count"),
)
- _, err := client.Cells.New(context.Background(), cercago.CellNewParams{
+ _, err := client.Agents.New(context.Background(), cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if err == nil {
@@ -133,7 +133,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
}),
option.WithHeader("X-Stainless-Retry-Count", "42"),
)
- _, err := client.Cells.New(context.Background(), cercago.CellNewParams{
+ _, err := client.Agents.New(context.Background(), cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if err == nil {
@@ -164,7 +164,7 @@ func TestRetryAfterMs(t *testing.T) {
},
}),
)
- _, err := client.Cells.New(context.Background(), cercago.CellNewParams{
+ _, err := client.Agents.New(context.Background(), cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if err == nil {
@@ -189,7 +189,7 @@ func TestContextCancel(t *testing.T) {
)
cancelCtx, cancel := context.WithCancel(context.Background())
cancel()
- _, err := client.Cells.New(cancelCtx, cercago.CellNewParams{
+ _, err := client.Agents.New(cancelCtx, cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if err == nil {
@@ -211,7 +211,7 @@ func TestContextCancelDelay(t *testing.T) {
)
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
defer cancel()
- _, err := client.Cells.New(cancelCtx, cercago.CellNewParams{
+ _, err := client.Agents.New(cancelCtx, cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if err == nil {
@@ -239,7 +239,7 @@ func TestContextDeadline(t *testing.T) {
},
}),
)
- _, err := client.Cells.New(deadlineCtx, cercago.CellNewParams{
+ _, err := client.Agents.New(deadlineCtx, cercago.AgentNewParams{
UserID: cercago.F("user_abc123"),
})
if err == nil {
diff --git a/connection.go b/connection.go
new file mode 100644
index 0000000..1edd7f7
--- /dev/null
+++ b/connection.go
@@ -0,0 +1,169 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+)
+
+// ConnectionService contains methods and other services that help with interacting
+// with the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewConnectionService] method instead.
+type ConnectionService struct {
+ Options []option.RequestOption
+}
+
+// NewConnectionService generates a new service that applies the given options to
+// each request. These options are applied after the parent client's options (if
+// there is one), and before any request-specific options.
+func NewConnectionService(opts ...option.RequestOption) (r *ConnectionService) {
+ r = &ConnectionService{}
+ r.Options = opts
+ return
+}
+
+func (r *ConnectionService) List(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ConnectionListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/connections", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *ConnectionService) Attach(ctx context.Context, agentID string, body ConnectionAttachParams, opts ...option.RequestOption) (res *AttachedConnection, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/connections", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *ConnectionService) Detach(ctx context.Context, agentID string, connectionID string, opts ...option.RequestOption) (res *ConnectionDetachResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if connectionID == "" {
+ err = errors.New("missing required connectionId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/connections/%s", agentID, connectionID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+type AttachedConnection struct {
+ AttachedAt string `json:"attachedAt" api:"required"`
+ Metadata ToolConnectionMetadata `json:"metadata"`
+ JSON attachedConnectionJSON `json:"-"`
+ Connection
+}
+
+// attachedConnectionJSON contains the JSON metadata for the struct
+// [AttachedConnection]
+type attachedConnectionJSON struct {
+ AttachedAt apijson.Field
+ Metadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *AttachedConnection) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r attachedConnectionJSON) RawJSON() string {
+ return r.raw
+}
+
+type ToolConnectionMetadata map[string]string
+
+type ToolConnectionMetadataParam map[string]string
+
+type ConnectionListResponse struct {
+ Connections []AttachedConnection `json:"connections" api:"required"`
+ Cursor string `json:"cursor" api:"required,nullable"`
+ HasMore bool `json:"hasMore" api:"required"`
+ JSON connectionListResponseJSON `json:"-"`
+}
+
+// connectionListResponseJSON contains the JSON metadata for the struct
+// [ConnectionListResponse]
+type connectionListResponseJSON struct {
+ Connections apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConnectionListResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r connectionListResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ConnectionDetachResponse struct {
+ Success ConnectionDetachResponseSuccess `json:"success" api:"required"`
+ JSON connectionDetachResponseJSON `json:"-"`
+}
+
+// connectionDetachResponseJSON contains the JSON metadata for the struct
+// [ConnectionDetachResponse]
+type connectionDetachResponseJSON struct {
+ Success apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConnectionDetachResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r connectionDetachResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ConnectionDetachResponseSuccess bool
+
+const (
+ ConnectionDetachResponseSuccessTrue ConnectionDetachResponseSuccess = true
+)
+
+func (r ConnectionDetachResponseSuccess) IsKnown() bool {
+ switch r {
+ case ConnectionDetachResponseSuccessTrue:
+ return true
+ }
+ return false
+}
+
+type ConnectionAttachParams struct {
+ ConnectionID param.Field[string] `json:"connectionId" api:"required"`
+ Metadata param.Field[ToolConnectionMetadataParam] `json:"metadata"`
+}
+
+func (r ConnectionAttachParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/cellconnection_test.go b/connection_test.go
similarity index 80%
rename from cellconnection_test.go
rename to connection_test.go
index c5f2e96..4396e86 100644
--- a/cellconnection_test.go
+++ b/connection_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellConnectionList(t *testing.T) {
+func TestConnectionList(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,7 +25,7 @@ func TestCellConnectionList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Connections.List(context.TODO(), "cell_abc123")
+ _, err := client.Connections.List(context.TODO(), "agent_abc123")
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
@@ -35,7 +35,7 @@ func TestCellConnectionList(t *testing.T) {
}
}
-func TestCellConnectionAttachWithOptionalParams(t *testing.T) {
+func TestConnectionAttachWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -47,10 +47,10 @@ func TestCellConnectionAttachWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Connections.Attach(
+ _, err := client.Connections.Attach(
context.TODO(),
- "cell_abc123",
- cercago.CellConnectionAttachParams{
+ "agent_abc123",
+ cercago.ConnectionAttachParams{
ConnectionID: cercago.F("connectionId"),
Metadata: cercago.F(cercago.ToolConnectionMetadataParam{
"foo": "string",
@@ -66,7 +66,7 @@ func TestCellConnectionAttachWithOptionalParams(t *testing.T) {
}
}
-func TestCellConnectionDetach(t *testing.T) {
+func TestConnectionDetach(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -78,10 +78,10 @@ func TestCellConnectionDetach(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Connections.Detach(
+ _, err := client.Connections.Detach(
context.TODO(),
- "cell_abc123",
- "env:org_abc123:env_abc123::conn_abc123",
+ "agent_abc123",
+ "env:org_abc123:fleet_abc123::conn_abc123",
)
if err != nil {
var apierr *cercago.Error
diff --git a/context.go b/context.go
new file mode 100644
index 0000000..dc34a89
--- /dev/null
+++ b/context.go
@@ -0,0 +1,319 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+)
+
+// ContextService contains methods and other services that help with interacting
+// with the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewContextService] method instead.
+type ContextService struct {
+ Options []option.RequestOption
+}
+
+// NewContextService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewContextService(opts ...option.RequestOption) (r *ContextService) {
+ r = &ContextService{}
+ r.Options = opts
+ return
+}
+
+func (r *ContextService) Get(ctx context.Context, agentID string, query ContextGetParams, opts ...option.RequestOption) (res *Entry, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/context/entry", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
+ return res, err
+}
+
+func (r *ContextService) List(ctx context.Context, agentID string, query ContextListParams, opts ...option.RequestOption) (res *pagination.EntriesCursorPage[EntrySummary], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/context", agentID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ContextService) ListAutoPaging(ctx context.Context, agentID string, query ContextListParams, opts ...option.RequestOption) *pagination.EntriesCursorPageAutoPager[EntrySummary] {
+ return pagination.NewEntriesCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
+}
+
+func (r *ContextService) Delete(ctx context.Context, agentID string, body ContextDeleteParams, opts ...option.RequestOption) (res *ContextDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/context/entry", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *ContextService) Search(ctx context.Context, agentID string, query ContextSearchParams, opts ...option.RequestOption) (res *pagination.ResultsCursorPage[SearchResult], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/context/search", agentID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ContextService) SearchAutoPaging(ctx context.Context, agentID string, query ContextSearchParams, opts ...option.RequestOption) *pagination.ResultsCursorPageAutoPager[SearchResult] {
+ return pagination.NewResultsCursorPageAutoPager(r.Search(ctx, agentID, query, opts...))
+}
+
+func (r *ContextService) Write(ctx context.Context, agentID string, body ContextWriteParams, opts ...option.RequestOption) (res *Entry, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/context/entry", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
+ return res, err
+}
+
+type Entry struct {
+ Content string `json:"content" api:"required"`
+ Key string `json:"key" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ MimeType string `json:"mimeType"`
+ JSON entryJSON `json:"-"`
+}
+
+// entryJSON contains the JSON metadata for the struct [Entry]
+type entryJSON struct {
+ Content apijson.Field
+ Key apijson.Field
+ UpdatedAt apijson.Field
+ Version apijson.Field
+ MimeType apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Entry) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r entryJSON) RawJSON() string {
+ return r.raw
+}
+
+type EntrySummary struct {
+ ByteLength float64 `json:"byteLength" api:"required"`
+ Key string `json:"key" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ MimeType string `json:"mimeType"`
+ JSON entrySummaryJSON `json:"-"`
+}
+
+// entrySummaryJSON contains the JSON metadata for the struct [EntrySummary]
+type entrySummaryJSON struct {
+ ByteLength apijson.Field
+ Key apijson.Field
+ UpdatedAt apijson.Field
+ Version apijson.Field
+ MimeType apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *EntrySummary) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r entrySummaryJSON) RawJSON() string {
+ return r.raw
+}
+
+type SearchResult struct {
+ ByteLength float64 `json:"byteLength" api:"required"`
+ Key string `json:"key" api:"required"`
+ Score float64 `json:"score" api:"required"`
+ Snippet string `json:"snippet" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ MimeType string `json:"mimeType"`
+ JSON searchResultJSON `json:"-"`
+}
+
+// searchResultJSON contains the JSON metadata for the struct [SearchResult]
+type searchResultJSON struct {
+ ByteLength apijson.Field
+ Key apijson.Field
+ Score apijson.Field
+ Snippet apijson.Field
+ UpdatedAt apijson.Field
+ Version apijson.Field
+ MimeType apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SearchResult) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r searchResultJSON) RawJSON() string {
+ return r.raw
+}
+
+type ContextDeleteResponse struct {
+ Success ContextDeleteResponseSuccess `json:"success" api:"required"`
+ JSON contextDeleteResponseJSON `json:"-"`
+}
+
+// contextDeleteResponseJSON contains the JSON metadata for the struct
+// [ContextDeleteResponse]
+type contextDeleteResponseJSON struct {
+ Success apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ContextDeleteResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r contextDeleteResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ContextDeleteResponseSuccess bool
+
+const (
+ ContextDeleteResponseSuccessTrue ContextDeleteResponseSuccess = true
+)
+
+func (r ContextDeleteResponseSuccess) IsKnown() bool {
+ switch r {
+ case ContextDeleteResponseSuccessTrue:
+ return true
+ }
+ return false
+}
+
+type ContextGetParams struct {
+ // Context entry key.
+ Key param.Field[string] `query:"key" api:"required"`
+}
+
+// URLQuery serializes [ContextGetParams]'s query parameters as `url.Values`.
+func (r ContextGetParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+type ContextListParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+ // Optional key prefix filter.
+ Prefix param.Field[string] `query:"prefix"`
+}
+
+// URLQuery serializes [ContextListParams]'s query parameters as `url.Values`.
+func (r ContextListParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+type ContextDeleteParams struct {
+ // Context entry key.
+ Key param.Field[string] `query:"key" api:"required"`
+}
+
+// URLQuery serializes [ContextDeleteParams]'s query parameters as `url.Values`.
+func (r ContextDeleteParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+type ContextSearchParams struct {
+ // Search query.
+ Q param.Field[string] `query:"q" api:"required"`
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+ // Optional key prefix filter.
+ Prefix param.Field[string] `query:"prefix"`
+}
+
+// URLQuery serializes [ContextSearchParams]'s query parameters as `url.Values`.
+func (r ContextSearchParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+type ContextWriteParams struct {
+ Content param.Field[string] `json:"content" api:"required"`
+ Key param.Field[string] `json:"key" api:"required"`
+ ExpectedVersion param.Field[float64] `json:"expectedVersion"`
+ MimeType param.Field[string] `json:"mimeType"`
+}
+
+func (r ContextWriteParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/context_test.go b/context_test.go
new file mode 100644
index 0000000..229cd31
--- /dev/null
+++ b/context_test.go
@@ -0,0 +1,162 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago_test
+
+import (
+ "context"
+ "errors"
+ "os"
+ "testing"
+
+ "github.com/matrices/cerca-go"
+ "github.com/matrices/cerca-go/internal/testutil"
+ "github.com/matrices/cerca-go/option"
+)
+
+func TestContextGet(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Context.Get(
+ context.TODO(),
+ "agent_abc123",
+ cercago.ContextGetParams{
+ Key: cercago.F("notes/project.md"),
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestContextListWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Context.List(
+ context.TODO(),
+ "agent_abc123",
+ cercago.ContextListParams{
+ Cursor: cercago.F("cursor_abc123"),
+ Limit: cercago.F("20"),
+ Prefix: cercago.F("notes/"),
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestContextDelete(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Context.Delete(
+ context.TODO(),
+ "agent_abc123",
+ cercago.ContextDeleteParams{
+ Key: cercago.F("notes/project.md"),
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestContextSearchWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Context.Search(
+ context.TODO(),
+ "agent_abc123",
+ cercago.ContextSearchParams{
+ Q: cercago.F("project notes"),
+ Cursor: cercago.F("cursor_abc123"),
+ Limit: cercago.F("20"),
+ Prefix: cercago.F("notes/"),
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestContextWriteWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Context.Write(
+ context.TODO(),
+ "agent_abc123",
+ cercago.ContextWriteParams{
+ Content: cercago.F("content"),
+ Key: cercago.F("key"),
+ ExpectedVersion: cercago.F(0.000000),
+ MimeType: cercago.F("mimeType"),
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
diff --git a/credential.go b/credential.go
index f53a378..a4e7aab 100644
--- a/credential.go
+++ b/credential.go
@@ -15,6 +15,7 @@ import (
"github.com/matrices/cerca-go/internal/param"
"github.com/matrices/cerca-go/internal/requestconfig"
"github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
)
// CredentialService contains methods and other services that help with interacting
@@ -36,15 +37,29 @@ func NewCredentialService(opts ...option.RequestOption) (r *CredentialService) {
return
}
-func (r *CredentialService) List(ctx context.Context, scope string, query CredentialListParams, opts ...option.RequestOption) (res *CredentialListResponse, err error) {
+func (r *CredentialService) List(ctx context.Context, scope string, query CredentialListParams, opts ...option.RequestOption) (res *pagination.ConnectionsCursorPage[Connection], err error) {
+ var raw *http.Response
opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if scope == "" {
err = errors.New("missing required scope parameter")
return nil, err
}
path := fmt.Sprintf("credentials/%s", scope)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *CredentialService) ListAutoPaging(ctx context.Context, scope string, query CredentialListParams, opts ...option.RequestOption) *pagination.ConnectionsCursorPageAutoPager[Connection] {
+ return pagination.NewConnectionsCursorPageAutoPager(r.List(ctx, scope, query, opts...))
}
func (r *CredentialService) Delete(ctx context.Context, scope string, connectionID string, opts ...option.RequestOption) (res *CredentialDeleteResponse, err error) {
@@ -143,31 +158,6 @@ func (r CredentialType) IsKnown() bool {
return false
}
-type CredentialListResponse struct {
- Connections []Connection `json:"connections" api:"required"`
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON credentialListResponseJSON `json:"-"`
-}
-
-// credentialListResponseJSON contains the JSON metadata for the struct
-// [CredentialListResponse]
-type credentialListResponseJSON struct {
- Connections apijson.Field
- Cursor apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CredentialListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r credentialListResponseJSON) RawJSON() string {
- return r.raw
-}
-
type CredentialDeleteResponse struct {
Success CredentialDeleteResponseSuccess `json:"success" api:"required"`
JSON credentialDeleteResponseJSON `json:"-"`
diff --git a/credential_test.go b/credential_test.go
index 5f2d503..bf1c23a 100644
--- a/credential_test.go
+++ b/credential_test.go
@@ -27,7 +27,7 @@ func TestCredentialListWithOptionalParams(t *testing.T) {
)
_, err := client.Credentials.List(
context.TODO(),
- "env:org_abc123:env_abc123",
+ "env:org_abc123:fleet_abc123",
cercago.CredentialListParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
@@ -56,8 +56,8 @@ func TestCredentialDelete(t *testing.T) {
)
_, err := client.Credentials.Delete(
context.TODO(),
- "env:org_abc123:env_abc123",
- "env:org_abc123:env_abc123::conn_abc123",
+ "env:org_abc123:fleet_abc123",
+ "env:org_abc123:fleet_abc123::conn_abc123",
)
if err != nil {
var apierr *cercago.Error
@@ -82,7 +82,7 @@ func TestCredentialNewAPIKeyWithOptionalParams(t *testing.T) {
)
_, err := client.Credentials.NewAPIKey(
context.TODO(),
- "env:org_abc123:env_abc123",
+ "env:org_abc123:fleet_abc123",
cercago.CredentialNewAPIKeyParams{
APIKey: cercago.F("sk_live_..."),
Provider: cercago.F("custom"),
diff --git a/environment.go b/environment.go
deleted file mode 100644
index 901bca7..0000000
--- a/environment.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/option"
-)
-
-// EnvironmentService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewEnvironmentService] method instead.
-type EnvironmentService struct {
- Options []option.RequestOption
- ToolSources *EnvironmentToolSourceService
- Webhooks *EnvironmentWebhookService
- Events *EnvironmentEventService
-}
-
-// NewEnvironmentService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewEnvironmentService(opts ...option.RequestOption) (r *EnvironmentService) {
- r = &EnvironmentService{}
- r.Options = opts
- r.ToolSources = NewEnvironmentToolSourceService(opts...)
- r.Webhooks = NewEnvironmentWebhookService(opts...)
- r.Events = NewEnvironmentEventService(opts...)
- return
-}
-
-type Environment struct {
- ID string `json:"id" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Name string `json:"name" api:"required"`
- OrgID string `json:"orgId" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- JSON environmentJSON `json:"-"`
-}
-
-// environmentJSON contains the JSON metadata for the struct [Environment]
-type environmentJSON struct {
- ID apijson.Field
- CreatedAt apijson.Field
- Name apijson.Field
- OrgID apijson.Field
- UpdatedAt apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *Environment) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r environmentJSON) RawJSON() string {
- return r.raw
-}
diff --git a/environmentevent.go b/environmentevent.go
deleted file mode 100644
index 3f5f71e..0000000
--- a/environmentevent.go
+++ /dev/null
@@ -1,237 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// EnvironmentEventService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewEnvironmentEventService] method instead.
-type EnvironmentEventService struct {
- Options []option.RequestOption
-}
-
-// NewEnvironmentEventService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewEnvironmentEventService(opts ...option.RequestOption) (r *EnvironmentEventService) {
- r = &EnvironmentEventService{}
- r.Options = opts
- return
-}
-
-func (r *EnvironmentEventService) List(ctx context.Context, envID string, query EnvironmentEventListParams, opts ...option.RequestOption) (res *EnvironmentEventListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if envID == "" {
- err = errors.New("missing required envId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/events", envID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-// WebSocket upgrade endpoint. Set
-// `Sec-WebSocket-Protocol: cell-v1, cell-auth-` so the runtime can
-// authenticate the stream while preserving the public subprotocol. HTTP clients
-// that cannot upgrade should use `/environments/{envId}/events` as the polling
-// analog.
-func (r *EnvironmentEventService) Subscribe(ctx context.Context, envID string, opts ...option.RequestOption) (res *EnvironmentEventSubscribeResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if envID == "" {
- err = errors.New("missing required envId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/events/subscribe", envID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-type RuntimeWebhookEvent struct {
- ID string `json:"id" api:"required"`
- CellID string `json:"cellId" api:"required"`
- Data map[string]interface{} `json:"data" api:"required"`
- EnvironmentID string `json:"environmentId" api:"required"`
- Event RuntimeWebhookEventType `json:"event" api:"required"`
- OrgID string `json:"orgId" api:"required"`
- ThreadID string `json:"threadId" api:"required,nullable"`
- Timestamp string `json:"timestamp" api:"required"`
- JSON runtimeWebhookEventJSON `json:"-"`
-}
-
-// runtimeWebhookEventJSON contains the JSON metadata for the struct
-// [RuntimeWebhookEvent]
-type runtimeWebhookEventJSON struct {
- ID apijson.Field
- CellID apijson.Field
- Data apijson.Field
- EnvironmentID apijson.Field
- Event apijson.Field
- OrgID apijson.Field
- ThreadID apijson.Field
- Timestamp apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *RuntimeWebhookEvent) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r runtimeWebhookEventJSON) RawJSON() string {
- return r.raw
-}
-
-type RuntimeWebhookEventType string
-
-const (
- RuntimeWebhookEventTypeCellCreated RuntimeWebhookEventType = "cell.created"
- RuntimeWebhookEventTypeCellUpdated RuntimeWebhookEventType = "cell.updated"
- RuntimeWebhookEventTypeCellDeleted RuntimeWebhookEventType = "cell.deleted"
- RuntimeWebhookEventTypeThreadCreated RuntimeWebhookEventType = "thread.created"
- RuntimeWebhookEventTypeThreadStatusChanged RuntimeWebhookEventType = "thread.status.changed"
- RuntimeWebhookEventTypeThreadCompleted RuntimeWebhookEventType = "thread.completed"
- RuntimeWebhookEventTypeThreadFailed RuntimeWebhookEventType = "thread.failed"
- RuntimeWebhookEventTypeTurnCreated RuntimeWebhookEventType = "turn.created"
- RuntimeWebhookEventTypeTurnCompleted RuntimeWebhookEventType = "turn.completed"
- RuntimeWebhookEventTypeTurnFailed RuntimeWebhookEventType = "turn.failed"
- RuntimeWebhookEventTypeMessageCreated RuntimeWebhookEventType = "message.created"
- RuntimeWebhookEventTypeApprovalRequested RuntimeWebhookEventType = "approval.requested"
- RuntimeWebhookEventTypeApprovalResolved RuntimeWebhookEventType = "approval.resolved"
- RuntimeWebhookEventTypeScheduleCreated RuntimeWebhookEventType = "schedule.created"
- RuntimeWebhookEventTypeScheduleDeleted RuntimeWebhookEventType = "schedule.deleted"
- RuntimeWebhookEventTypeScheduleTriggered RuntimeWebhookEventType = "schedule.triggered"
- RuntimeWebhookEventTypeConnectionAttached RuntimeWebhookEventType = "connection.attached"
- RuntimeWebhookEventTypeConnectionDetached RuntimeWebhookEventType = "connection.detached"
- RuntimeWebhookEventTypeWebhookTest RuntimeWebhookEventType = "webhook.test"
-)
-
-func (r RuntimeWebhookEventType) IsKnown() bool {
- switch r {
- case RuntimeWebhookEventTypeCellCreated, RuntimeWebhookEventTypeCellUpdated, RuntimeWebhookEventTypeCellDeleted, RuntimeWebhookEventTypeThreadCreated, RuntimeWebhookEventTypeThreadStatusChanged, RuntimeWebhookEventTypeThreadCompleted, RuntimeWebhookEventTypeThreadFailed, RuntimeWebhookEventTypeTurnCreated, RuntimeWebhookEventTypeTurnCompleted, RuntimeWebhookEventTypeTurnFailed, RuntimeWebhookEventTypeMessageCreated, RuntimeWebhookEventTypeApprovalRequested, RuntimeWebhookEventTypeApprovalResolved, RuntimeWebhookEventTypeScheduleCreated, RuntimeWebhookEventTypeScheduleDeleted, RuntimeWebhookEventTypeScheduleTriggered, RuntimeWebhookEventTypeConnectionAttached, RuntimeWebhookEventTypeConnectionDetached, RuntimeWebhookEventTypeWebhookTest:
- return true
- }
- return false
-}
-
-type SubscriptionEvent struct {
- Event RuntimeWebhookEvent `json:"event" api:"required"`
- Seq float64 `json:"seq" api:"required"`
- JSON subscriptionEventJSON `json:"-"`
-}
-
-// subscriptionEventJSON contains the JSON metadata for the struct
-// [SubscriptionEvent]
-type subscriptionEventJSON struct {
- Event apijson.Field
- Seq apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *SubscriptionEvent) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r subscriptionEventJSON) RawJSON() string {
- return r.raw
-}
-
-type EnvironmentEventListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- Events []SubscriptionEvent `json:"events" api:"required"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON environmentEventListResponseJSON `json:"-"`
-}
-
-// environmentEventListResponseJSON contains the JSON metadata for the struct
-// [EnvironmentEventListResponse]
-type environmentEventListResponseJSON struct {
- Cursor apijson.Field
- Events apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *EnvironmentEventListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r environmentEventListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type EnvironmentEventSubscribeResponse struct {
- Error string `json:"error" api:"required"`
- JSON environmentEventSubscribeResponseJSON `json:"-"`
-}
-
-// environmentEventSubscribeResponseJSON contains the JSON metadata for the struct
-// [EnvironmentEventSubscribeResponse]
-type environmentEventSubscribeResponseJSON struct {
- Error apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *EnvironmentEventSubscribeResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r environmentEventSubscribeResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type EnvironmentEventListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Comma-separated event type filter.
- Events param.Field[string] `query:"events"`
- // When true, starts from the beginning of the retained buffer.
- History param.Field[EnvironmentEventListParamsHistory] `query:"history"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [EnvironmentEventListParams]'s query parameters as
-// `url.Values`.
-func (r EnvironmentEventListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-// When true, starts from the beginning of the retained buffer.
-type EnvironmentEventListParamsHistory string
-
-const (
- EnvironmentEventListParamsHistoryTrue EnvironmentEventListParamsHistory = "true"
- EnvironmentEventListParamsHistoryFalse EnvironmentEventListParamsHistory = "false"
-)
-
-func (r EnvironmentEventListParamsHistory) IsKnown() bool {
- switch r {
- case EnvironmentEventListParamsHistoryTrue, EnvironmentEventListParamsHistoryFalse:
- return true
- }
- return false
-}
diff --git a/environmentevent_test.go b/environmentevent_test.go
deleted file mode 100644
index 0591b44..0000000
--- a/environmentevent_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestEnvironmentEventListWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Environments.Events.List(
- context.TODO(),
- "env_abc123",
- cercago.EnvironmentEventListParams{
- Cursor: cercago.F("cursor_abc123"),
- Events: cercago.F("thread.created,thread.completed"),
- History: cercago.F(cercago.EnvironmentEventListParamsHistoryTrue),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestEnvironmentEventSubscribe(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Environments.Events.Subscribe(context.TODO(), "env_abc123")
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/environmenttoolsource.go b/environmenttoolsource.go
deleted file mode 100644
index ebbcd32..0000000
--- a/environmenttoolsource.go
+++ /dev/null
@@ -1,562 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "reflect"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
- "github.com/tidwall/gjson"
-)
-
-// EnvironmentToolSourceService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewEnvironmentToolSourceService] method instead.
-type EnvironmentToolSourceService struct {
- Options []option.RequestOption
-}
-
-// NewEnvironmentToolSourceService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewEnvironmentToolSourceService(opts ...option.RequestOption) (r *EnvironmentToolSourceService) {
- r = &EnvironmentToolSourceService{}
- r.Options = opts
- return
-}
-
-func (r *EnvironmentToolSourceService) New(ctx context.Context, environmentID string, body EnvironmentToolSourceNewParams, opts ...option.RequestOption) (res *ToolSource, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/tool-sources", environmentID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentToolSourceService) Get(ctx context.Context, environmentID string, sourceID string, opts ...option.RequestOption) (res *ToolSource, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- if sourceID == "" {
- err = errors.New("missing required sourceId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/tool-sources/%s", environmentID, sourceID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentToolSourceService) Update(ctx context.Context, environmentID string, sourceID string, body EnvironmentToolSourceUpdateParams, opts ...option.RequestOption) (res *ToolSource, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- if sourceID == "" {
- err = errors.New("missing required sourceId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/tool-sources/%s", environmentID, sourceID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentToolSourceService) List(ctx context.Context, environmentID string, query EnvironmentToolSourceListParams, opts ...option.RequestOption) (res *EnvironmentToolSourceListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/tool-sources", environmentID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentToolSourceService) Delete(ctx context.Context, environmentID string, sourceID string, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
- opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return err
- }
- if sourceID == "" {
- err = errors.New("missing required sourceId parameter")
- return err
- }
- path := fmt.Sprintf("environments/%s/tool-sources/%s", environmentID, sourceID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
- return err
-}
-
-type HTTPToolDefinition = interface{}
-
-type HTTPToolExecutionPolicy = interface{}
-
-type HTTPToolSource struct {
- ID string `json:"id" api:"required"`
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth ToolSourceAuth `json:"auth" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- EnvironmentID string `json:"environmentId" api:"required"`
- Namespace string `json:"namespace" api:"required"`
- Tools []HTTPToolDefinition `json:"tools" api:"required"`
- Type HTTPToolSourceType `json:"type" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Version float64 `json:"version" api:"required"`
- Approval ToolApprovalMode `json:"approval"`
- // HTTP tool execution retry and timeout policy.
- Execution HTTPToolExecutionPolicy `json:"execution"`
- JSON httpToolSourceJSON `json:"-"`
-}
-
-// httpToolSourceJSON contains the JSON metadata for the struct [HTTPToolSource]
-type httpToolSourceJSON struct {
- ID apijson.Field
- Auth apijson.Field
- CreatedAt apijson.Field
- Enabled apijson.Field
- EnvironmentID apijson.Field
- Namespace apijson.Field
- Tools apijson.Field
- Type apijson.Field
- UpdatedAt apijson.Field
- Version apijson.Field
- Approval apijson.Field
- Execution apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *HTTPToolSource) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r httpToolSourceJSON) RawJSON() string {
- return r.raw
-}
-
-func (r HTTPToolSource) implementsToolSource() {}
-
-type HTTPToolSourceType string
-
-const (
- HTTPToolSourceTypeHTTP HTTPToolSourceType = "http"
-)
-
-func (r HTTPToolSourceType) IsKnown() bool {
- switch r {
- case HTTPToolSourceTypeHTTP:
- return true
- }
- return false
-}
-
-type McpToolExecutionPolicy = interface{}
-
-type McpToolSource struct {
- ID string `json:"id" api:"required"`
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth ToolSourceAuth `json:"auth" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- EnvironmentID string `json:"environmentId" api:"required"`
- Namespace string `json:"namespace" api:"required"`
- Type McpToolSourceType `json:"type" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- URL string `json:"url" api:"required"`
- Version float64 `json:"version" api:"required"`
- Approval ToolApprovalMode `json:"approval"`
- // MCP discovery and execution retry/timeout policy.
- Execution McpToolExecutionPolicy `json:"execution"`
- JSON mcpToolSourceJSON `json:"-"`
-}
-
-// mcpToolSourceJSON contains the JSON metadata for the struct [McpToolSource]
-type mcpToolSourceJSON struct {
- ID apijson.Field
- Auth apijson.Field
- CreatedAt apijson.Field
- Enabled apijson.Field
- EnvironmentID apijson.Field
- Namespace apijson.Field
- Type apijson.Field
- UpdatedAt apijson.Field
- URL apijson.Field
- Version apijson.Field
- Approval apijson.Field
- Execution apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *McpToolSource) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r mcpToolSourceJSON) RawJSON() string {
- return r.raw
-}
-
-func (r McpToolSource) implementsToolSource() {}
-
-type McpToolSourceType string
-
-const (
- McpToolSourceTypeMcp McpToolSourceType = "mcp"
-)
-
-func (r McpToolSourceType) IsKnown() bool {
- switch r {
- case McpToolSourceTypeMcp:
- return true
- }
- return false
-}
-
-type ToolApprovalMode string
-
-const (
- ToolApprovalModeAlways ToolApprovalMode = "always"
- ToolApprovalModeNever ToolApprovalMode = "never"
-)
-
-func (r ToolApprovalMode) IsKnown() bool {
- switch r {
- case ToolApprovalModeAlways, ToolApprovalModeNever:
- return true
- }
- return false
-}
-
-type ToolSource struct {
- ID string `json:"id" api:"required"`
- // This field can have the runtime type of [ToolSourceAuth].
- Auth ToolSourceAuth `json:"auth" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- EnvironmentID string `json:"environmentId" api:"required"`
- Namespace string `json:"namespace" api:"required"`
- Type ToolSourceType `json:"type" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Version float64 `json:"version" api:"required"`
- Approval ToolApprovalMode `json:"approval"`
- // This field can have the runtime type of [HTTPToolExecutionPolicy],
- // [McpToolExecutionPolicy].
- Execution interface{} `json:"execution"`
- // This field can have the runtime type of [[]HTTPToolDefinition].
- Tools interface{} `json:"tools"`
- URL string `json:"url"`
- JSON toolSourceJSON `json:"-"`
- union ToolSourceUnion
-}
-
-// toolSourceJSON contains the JSON metadata for the struct [ToolSource]
-type toolSourceJSON struct {
- ID apijson.Field
- Auth apijson.Field
- CreatedAt apijson.Field
- Enabled apijson.Field
- EnvironmentID apijson.Field
- Namespace apijson.Field
- Type apijson.Field
- UpdatedAt apijson.Field
- Version apijson.Field
- Approval apijson.Field
- Execution apijson.Field
- Tools apijson.Field
- URL apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r toolSourceJSON) RawJSON() string {
- return r.raw
-}
-
-func (r *ToolSource) UnmarshalJSON(data []byte) (err error) {
- *r = ToolSource{}
- err = apijson.UnmarshalRoot(data, &r.union)
- if err != nil {
- return err
- }
- return apijson.Port(r.union, &r)
-}
-
-// AsUnion returns a [ToolSourceUnion] interface which you can cast to the specific
-// types for more type safety.
-//
-// Possible runtime types of the union are [HTTPToolSource], [McpToolSource].
-func (r ToolSource) AsUnion() ToolSourceUnion {
- return r.union
-}
-
-// Union satisfied by [HTTPToolSource] or [McpToolSource].
-type ToolSourceUnion interface {
- implementsToolSource()
-}
-
-func init() {
- apijson.RegisterUnion(
- reflect.TypeOf((*ToolSourceUnion)(nil)).Elem(),
- "type",
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(HTTPToolSource{}),
- DiscriminatorValue: "http",
- },
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(McpToolSource{}),
- DiscriminatorValue: "mcp",
- },
- )
-}
-
-type ToolSourceType string
-
-const (
- ToolSourceTypeHTTP ToolSourceType = "http"
- ToolSourceTypeMcp ToolSourceType = "mcp"
-)
-
-func (r ToolSourceType) IsKnown() bool {
- switch r {
- case ToolSourceTypeHTTP, ToolSourceTypeMcp:
- return true
- }
- return false
-}
-
-type ToolSourceAuth = interface{}
-
-type EnvironmentToolSourceListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- Sources []ToolSource `json:"sources" api:"required"`
- JSON environmentToolSourceListResponseJSON `json:"-"`
-}
-
-// environmentToolSourceListResponseJSON contains the JSON metadata for the struct
-// [EnvironmentToolSourceListResponse]
-type environmentToolSourceListResponseJSON struct {
- Cursor apijson.Field
- HasMore apijson.Field
- Sources apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *EnvironmentToolSourceListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r environmentToolSourceListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type EnvironmentToolSourceNewParams struct {
- Body EnvironmentToolSourceNewParamsBodyUnion `json:"body" api:"required"`
-}
-
-func (r EnvironmentToolSourceNewParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r.Body)
-}
-
-type EnvironmentToolSourceNewParamsBody struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[EnvironmentToolSourceNewParamsBodyType] `json:"type" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- Execution param.Field[interface{}] `json:"execution"`
- Tools param.Field[interface{}] `json:"tools"`
- URL param.Field[string] `json:"url"`
-}
-
-func (r EnvironmentToolSourceNewParamsBody) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r EnvironmentToolSourceNewParamsBody) implementsEnvironmentToolSourceNewParamsBodyUnion() {}
-
-// Satisfied by [EnvironmentToolSourceNewParamsBodyObject],
-// [EnvironmentToolSourceNewParamsBodyObject],
-// [EnvironmentToolSourceNewParamsBody].
-type EnvironmentToolSourceNewParamsBodyUnion interface {
- implementsEnvironmentToolSourceNewParamsBodyUnion()
-}
-
-type EnvironmentToolSourceNewParamsBodyObject struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
- Type param.Field[EnvironmentToolSourceNewParamsBodyObjectType] `json:"type" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- // HTTP tool execution retry and timeout policy.
- Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
- ExtraFields map[string]interface{} `json:"-,extras"`
-}
-
-func (r EnvironmentToolSourceNewParamsBodyObject) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r EnvironmentToolSourceNewParamsBodyObject) implementsEnvironmentToolSourceNewParamsBodyUnion() {
-}
-
-type EnvironmentToolSourceNewParamsBodyObjectType string
-
-const (
- EnvironmentToolSourceNewParamsBodyObjectTypeHTTP EnvironmentToolSourceNewParamsBodyObjectType = "http"
-)
-
-func (r EnvironmentToolSourceNewParamsBodyObjectType) IsKnown() bool {
- switch r {
- case EnvironmentToolSourceNewParamsBodyObjectTypeHTTP:
- return true
- }
- return false
-}
-
-type EnvironmentToolSourceNewParamsBodyType string
-
-const (
- EnvironmentToolSourceNewParamsBodyTypeHTTP EnvironmentToolSourceNewParamsBodyType = "http"
- EnvironmentToolSourceNewParamsBodyTypeMcp EnvironmentToolSourceNewParamsBodyType = "mcp"
-)
-
-func (r EnvironmentToolSourceNewParamsBodyType) IsKnown() bool {
- switch r {
- case EnvironmentToolSourceNewParamsBodyTypeHTTP, EnvironmentToolSourceNewParamsBodyTypeMcp:
- return true
- }
- return false
-}
-
-type EnvironmentToolSourceUpdateParams struct {
- Body EnvironmentToolSourceUpdateParamsBodyUnion `json:"body" api:"required"`
-}
-
-func (r EnvironmentToolSourceUpdateParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r.Body)
-}
-
-type EnvironmentToolSourceUpdateParamsBody struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[EnvironmentToolSourceUpdateParamsBodyType] `json:"type" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- Execution param.Field[interface{}] `json:"execution"`
- Tools param.Field[interface{}] `json:"tools"`
- URL param.Field[string] `json:"url"`
-}
-
-func (r EnvironmentToolSourceUpdateParamsBody) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r EnvironmentToolSourceUpdateParamsBody) implementsEnvironmentToolSourceUpdateParamsBodyUnion() {
-}
-
-// Satisfied by [EnvironmentToolSourceUpdateParamsBodyObject],
-// [EnvironmentToolSourceUpdateParamsBodyObject],
-// [EnvironmentToolSourceUpdateParamsBody].
-type EnvironmentToolSourceUpdateParamsBodyUnion interface {
- implementsEnvironmentToolSourceUpdateParamsBodyUnion()
-}
-
-type EnvironmentToolSourceUpdateParamsBodyObject struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
- Type param.Field[EnvironmentToolSourceUpdateParamsBodyObjectType] `json:"type" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- // HTTP tool execution retry and timeout policy.
- Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
- ExtraFields map[string]interface{} `json:"-,extras"`
-}
-
-func (r EnvironmentToolSourceUpdateParamsBodyObject) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r EnvironmentToolSourceUpdateParamsBodyObject) implementsEnvironmentToolSourceUpdateParamsBodyUnion() {
-}
-
-type EnvironmentToolSourceUpdateParamsBodyObjectType string
-
-const (
- EnvironmentToolSourceUpdateParamsBodyObjectTypeHTTP EnvironmentToolSourceUpdateParamsBodyObjectType = "http"
-)
-
-func (r EnvironmentToolSourceUpdateParamsBodyObjectType) IsKnown() bool {
- switch r {
- case EnvironmentToolSourceUpdateParamsBodyObjectTypeHTTP:
- return true
- }
- return false
-}
-
-type EnvironmentToolSourceUpdateParamsBodyType string
-
-const (
- EnvironmentToolSourceUpdateParamsBodyTypeHTTP EnvironmentToolSourceUpdateParamsBodyType = "http"
- EnvironmentToolSourceUpdateParamsBodyTypeMcp EnvironmentToolSourceUpdateParamsBodyType = "mcp"
-)
-
-func (r EnvironmentToolSourceUpdateParamsBodyType) IsKnown() bool {
- switch r {
- case EnvironmentToolSourceUpdateParamsBodyTypeHTTP, EnvironmentToolSourceUpdateParamsBodyTypeMcp:
- return true
- }
- return false
-}
-
-type EnvironmentToolSourceListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [EnvironmentToolSourceListParams]'s query parameters as
-// `url.Values`.
-func (r EnvironmentToolSourceListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/environmentwebhook.go b/environmentwebhook.go
deleted file mode 100644
index 1c82910..0000000
--- a/environmentwebhook.go
+++ /dev/null
@@ -1,364 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
-)
-
-// EnvironmentWebhookService contains methods and other services that help with
-// interacting with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewEnvironmentWebhookService] method instead.
-type EnvironmentWebhookService struct {
- Options []option.RequestOption
-}
-
-// NewEnvironmentWebhookService generates a new service that applies the given
-// options to each request. These options are applied after the parent client's
-// options (if there is one), and before any request-specific options.
-func NewEnvironmentWebhookService(opts ...option.RequestOption) (r *EnvironmentWebhookService) {
- r = &EnvironmentWebhookService{}
- r.Options = opts
- return
-}
-
-func (r *EnvironmentWebhookService) New(ctx context.Context, environmentID string, body EnvironmentWebhookNewParams, opts ...option.RequestOption) (res *WebhookSubscriptionCreated, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/webhooks", environmentID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentWebhookService) Get(ctx context.Context, environmentID string, webhookID string, opts ...option.RequestOption) (res *WebhookSubscription, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- if webhookID == "" {
- err = errors.New("missing required webhookId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/webhooks/%s", environmentID, webhookID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentWebhookService) Update(ctx context.Context, environmentID string, webhookID string, body EnvironmentWebhookUpdateParams, opts ...option.RequestOption) (res *WebhookSubscription, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- if webhookID == "" {
- err = errors.New("missing required webhookId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/webhooks/%s", environmentID, webhookID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentWebhookService) List(ctx context.Context, environmentID string, query EnvironmentWebhookListParams, opts ...option.RequestOption) (res *EnvironmentWebhookListResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/webhooks", environmentID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentWebhookService) Delete(ctx context.Context, environmentID string, webhookID string, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
- opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return err
- }
- if webhookID == "" {
- err = errors.New("missing required webhookId parameter")
- return err
- }
- path := fmt.Sprintf("environments/%s/webhooks/%s", environmentID, webhookID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
- return err
-}
-
-func (r *EnvironmentWebhookService) Rotate(ctx context.Context, environmentID string, webhookID string, opts ...option.RequestOption) (res *WebhookSubscriptionCreated, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- if webhookID == "" {
- err = errors.New("missing required webhookId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/webhooks/%s/rotate", environmentID, webhookID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *EnvironmentWebhookService) Test(ctx context.Context, environmentID string, webhookID string, opts ...option.RequestOption) (res *EnvironmentWebhookTestResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if environmentID == "" {
- err = errors.New("missing required environmentId parameter")
- return nil, err
- }
- if webhookID == "" {
- err = errors.New("missing required webhookId parameter")
- return nil, err
- }
- path := fmt.Sprintf("environments/%s/webhooks/%s/test", environmentID, webhookID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
- return res, err
-}
-
-type WebhookEventType string
-
-const (
- WebhookEventTypeCellCreated WebhookEventType = "cell.created"
- WebhookEventTypeCellUpdated WebhookEventType = "cell.updated"
- WebhookEventTypeCellDeleted WebhookEventType = "cell.deleted"
- WebhookEventTypeThreadCreated WebhookEventType = "thread.created"
- WebhookEventTypeThreadStatusChanged WebhookEventType = "thread.status.changed"
- WebhookEventTypeThreadCompleted WebhookEventType = "thread.completed"
- WebhookEventTypeThreadFailed WebhookEventType = "thread.failed"
- WebhookEventTypeTurnCreated WebhookEventType = "turn.created"
- WebhookEventTypeTurnCompleted WebhookEventType = "turn.completed"
- WebhookEventTypeTurnFailed WebhookEventType = "turn.failed"
- WebhookEventTypeMessageCreated WebhookEventType = "message.created"
- WebhookEventTypeApprovalRequested WebhookEventType = "approval.requested"
- WebhookEventTypeApprovalResolved WebhookEventType = "approval.resolved"
- WebhookEventTypeScheduleCreated WebhookEventType = "schedule.created"
- WebhookEventTypeScheduleDeleted WebhookEventType = "schedule.deleted"
- WebhookEventTypeScheduleTriggered WebhookEventType = "schedule.triggered"
- WebhookEventTypeConnectionAttached WebhookEventType = "connection.attached"
- WebhookEventTypeConnectionDetached WebhookEventType = "connection.detached"
- WebhookEventTypeWebhookTest WebhookEventType = "webhook.test"
-)
-
-func (r WebhookEventType) IsKnown() bool {
- switch r {
- case WebhookEventTypeCellCreated, WebhookEventTypeCellUpdated, WebhookEventTypeCellDeleted, WebhookEventTypeThreadCreated, WebhookEventTypeThreadStatusChanged, WebhookEventTypeThreadCompleted, WebhookEventTypeThreadFailed, WebhookEventTypeTurnCreated, WebhookEventTypeTurnCompleted, WebhookEventTypeTurnFailed, WebhookEventTypeMessageCreated, WebhookEventTypeApprovalRequested, WebhookEventTypeApprovalResolved, WebhookEventTypeScheduleCreated, WebhookEventTypeScheduleDeleted, WebhookEventTypeScheduleTriggered, WebhookEventTypeConnectionAttached, WebhookEventTypeConnectionDetached, WebhookEventTypeWebhookTest:
- return true
- }
- return false
-}
-
-// Webhook subscription metadata returned by list, get, and update. The one-time
-// signing secret is not returned here.
-type WebhookSubscription struct {
- ID string `json:"id" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- EnvironmentID string `json:"environmentId" api:"required"`
- Events []WebhookEventType `json:"events" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- URL string `json:"url" api:"required"`
- JSON webhookSubscriptionJSON `json:"-"`
-}
-
-// webhookSubscriptionJSON contains the JSON metadata for the struct
-// [WebhookSubscription]
-type webhookSubscriptionJSON struct {
- ID apijson.Field
- CreatedAt apijson.Field
- Enabled apijson.Field
- EnvironmentID apijson.Field
- Events apijson.Field
- UpdatedAt apijson.Field
- URL apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *WebhookSubscription) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r webhookSubscriptionJSON) RawJSON() string {
- return r.raw
-}
-
-// Webhook subscription response for create and rotate. Includes the one-time
-// `secret` field.
-type WebhookSubscriptionCreated struct {
- ID string `json:"id" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- EnvironmentID string `json:"environmentId" api:"required"`
- Events []WebhookEventType `json:"events" api:"required"`
- // One-time webhook signing secret returned only by create and rotate responses.
- // The field name is `secret`.
- Secret string `json:"secret" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- URL string `json:"url" api:"required"`
- JSON webhookSubscriptionCreatedJSON `json:"-"`
-}
-
-// webhookSubscriptionCreatedJSON contains the JSON metadata for the struct
-// [WebhookSubscriptionCreated]
-type webhookSubscriptionCreatedJSON struct {
- ID apijson.Field
- CreatedAt apijson.Field
- Enabled apijson.Field
- EnvironmentID apijson.Field
- Events apijson.Field
- Secret apijson.Field
- UpdatedAt apijson.Field
- URL apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *WebhookSubscriptionCreated) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r webhookSubscriptionCreatedJSON) RawJSON() string {
- return r.raw
-}
-
-// `webhook.test` is reserved for the test endpoint and cannot be subscribed to.
-type WebhookSubscriptionEventType string
-
-const (
- WebhookSubscriptionEventTypeCellCreated WebhookSubscriptionEventType = "cell.created"
- WebhookSubscriptionEventTypeCellUpdated WebhookSubscriptionEventType = "cell.updated"
- WebhookSubscriptionEventTypeCellDeleted WebhookSubscriptionEventType = "cell.deleted"
- WebhookSubscriptionEventTypeThreadCreated WebhookSubscriptionEventType = "thread.created"
- WebhookSubscriptionEventTypeThreadStatusChanged WebhookSubscriptionEventType = "thread.status.changed"
- WebhookSubscriptionEventTypeThreadCompleted WebhookSubscriptionEventType = "thread.completed"
- WebhookSubscriptionEventTypeThreadFailed WebhookSubscriptionEventType = "thread.failed"
- WebhookSubscriptionEventTypeTurnCreated WebhookSubscriptionEventType = "turn.created"
- WebhookSubscriptionEventTypeTurnCompleted WebhookSubscriptionEventType = "turn.completed"
- WebhookSubscriptionEventTypeTurnFailed WebhookSubscriptionEventType = "turn.failed"
- WebhookSubscriptionEventTypeMessageCreated WebhookSubscriptionEventType = "message.created"
- WebhookSubscriptionEventTypeApprovalRequested WebhookSubscriptionEventType = "approval.requested"
- WebhookSubscriptionEventTypeApprovalResolved WebhookSubscriptionEventType = "approval.resolved"
- WebhookSubscriptionEventTypeScheduleCreated WebhookSubscriptionEventType = "schedule.created"
- WebhookSubscriptionEventTypeScheduleDeleted WebhookSubscriptionEventType = "schedule.deleted"
- WebhookSubscriptionEventTypeScheduleTriggered WebhookSubscriptionEventType = "schedule.triggered"
- WebhookSubscriptionEventTypeConnectionAttached WebhookSubscriptionEventType = "connection.attached"
- WebhookSubscriptionEventTypeConnectionDetached WebhookSubscriptionEventType = "connection.detached"
-)
-
-func (r WebhookSubscriptionEventType) IsKnown() bool {
- switch r {
- case WebhookSubscriptionEventTypeCellCreated, WebhookSubscriptionEventTypeCellUpdated, WebhookSubscriptionEventTypeCellDeleted, WebhookSubscriptionEventTypeThreadCreated, WebhookSubscriptionEventTypeThreadStatusChanged, WebhookSubscriptionEventTypeThreadCompleted, WebhookSubscriptionEventTypeThreadFailed, WebhookSubscriptionEventTypeTurnCreated, WebhookSubscriptionEventTypeTurnCompleted, WebhookSubscriptionEventTypeTurnFailed, WebhookSubscriptionEventTypeMessageCreated, WebhookSubscriptionEventTypeApprovalRequested, WebhookSubscriptionEventTypeApprovalResolved, WebhookSubscriptionEventTypeScheduleCreated, WebhookSubscriptionEventTypeScheduleDeleted, WebhookSubscriptionEventTypeScheduleTriggered, WebhookSubscriptionEventTypeConnectionAttached, WebhookSubscriptionEventTypeConnectionDetached:
- return true
- }
- return false
-}
-
-type EnvironmentWebhookListResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- Subscriptions []WebhookSubscription `json:"subscriptions" api:"required"`
- JSON environmentWebhookListResponseJSON `json:"-"`
-}
-
-// environmentWebhookListResponseJSON contains the JSON metadata for the struct
-// [EnvironmentWebhookListResponse]
-type environmentWebhookListResponseJSON struct {
- Cursor apijson.Field
- HasMore apijson.Field
- Subscriptions apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *EnvironmentWebhookListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r environmentWebhookListResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type EnvironmentWebhookTestResponse struct {
- Error string `json:"error" api:"required,nullable"`
- StatusCode int64 `json:"statusCode" api:"required,nullable"`
- Success bool `json:"success" api:"required"`
- JSON environmentWebhookTestResponseJSON `json:"-"`
-}
-
-// environmentWebhookTestResponseJSON contains the JSON metadata for the struct
-// [EnvironmentWebhookTestResponse]
-type environmentWebhookTestResponseJSON struct {
- Error apijson.Field
- StatusCode apijson.Field
- Success apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *EnvironmentWebhookTestResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r environmentWebhookTestResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type EnvironmentWebhookNewParams struct {
- // HTTPS endpoint that will receive webhook deliveries.
- URL param.Field[string] `json:"url" api:"required" format:"uri"`
- // Event names to deliver. Omit to subscribe to all non-test events.
- Events param.Field[[]WebhookSubscriptionEventType] `json:"events"`
-}
-
-func (r EnvironmentWebhookNewParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type EnvironmentWebhookUpdateParams struct {
- // Whether deliveries are enabled for this subscription.
- Enabled param.Field[bool] `json:"enabled"`
- // Event names to deliver. Omit to subscribe to all non-test events.
- Events param.Field[[]WebhookSubscriptionEventType] `json:"events"`
- // HTTPS endpoint that will receive webhook deliveries.
- URL param.Field[string] `json:"url" format:"uri"`
-}
-
-func (r EnvironmentWebhookUpdateParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-type EnvironmentWebhookListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [EnvironmentWebhookListParams]'s query parameters as
-// `url.Values`.
-func (r EnvironmentWebhookListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/event.go b/event.go
new file mode 100644
index 0000000..2003088
--- /dev/null
+++ b/event.go
@@ -0,0 +1,370 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+ "github.com/matrices/cerca-go/shared"
+)
+
+// EventService contains methods and other services that help with interacting with
+// the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewEventService] method instead.
+type EventService struct {
+ Options []option.RequestOption
+}
+
+// NewEventService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewEventService(opts ...option.RequestOption) (r *EventService) {
+ r = &EventService{}
+ r.Options = opts
+ return
+}
+
+func (r *EventService) ListForAgent(ctx context.Context, agentID string, query EventListForAgentParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/events", agentID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *EventService) ListForAgentAutoPaging(ctx context.Context, agentID string, query EventListForAgentParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
+ return pagination.NewEventsCursorPageAutoPager(r.ListForAgent(ctx, agentID, query, opts...))
+}
+
+func (r *EventService) ListForFleet(ctx context.Context, fleetID string, query EventListForFleetParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/events", fleetID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *EventService) ListForFleetAutoPaging(ctx context.Context, fleetID string, query EventListForFleetParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
+ return pagination.NewEventsCursorPageAutoPager(r.ListForFleet(ctx, fleetID, query, opts...))
+}
+
+func (r *EventService) ListForThread(ctx context.Context, agentID string, threadID string, query EventListForThreadParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/events", agentID, threadID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *EventService) ListForThreadAutoPaging(ctx context.Context, agentID string, threadID string, query EventListForThreadParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
+ return pagination.NewEventsCursorPageAutoPager(r.ListForThread(ctx, agentID, threadID, query, opts...))
+}
+
+// WebSocket upgrade endpoint. Set
+// `Sec-WebSocket-Protocol: agent-v1, agent-auth-` so the runtime can
+// authenticate the stream while preserving the public subprotocol. HTTP clients
+// that cannot upgrade should use `/agents/{agentId}/events` as the polling analog.
+func (r *EventService) SubscribeAgent(ctx context.Context, agentID string, opts ...option.RequestOption) (res *shared.ErrorResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/events/subscribe", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// WebSocket upgrade endpoint. Set
+// `Sec-WebSocket-Protocol: agent-v1, agent-auth-` so the runtime can
+// authenticate the stream while preserving the public subprotocol. HTTP clients
+// that cannot upgrade should use `/fleets/{fleetId}/events` as the polling analog.
+func (r *EventService) SubscribeFleet(ctx context.Context, fleetID string, opts ...option.RequestOption) (res *shared.ErrorResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/events/subscribe", fleetID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// WebSocket upgrade endpoint. Set
+// `Sec-WebSocket-Protocol: agent-v1, agent-auth-` so the runtime can
+// authenticate the stream while preserving the public subprotocol. HTTP clients
+// that cannot upgrade should use `/agents/{agentId}/threads/{threadId}/events` as
+// the polling analog.
+func (r *EventService) SubscribeThread(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (res *shared.ErrorResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/events/subscribe", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+type RuntimeWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data map[string]interface{} `json:"data" api:"required"`
+ Event RuntimeWebhookEventType `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventJSON contains the JSON metadata for the struct
+// [RuntimeWebhookEvent]
+type runtimeWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventType string
+
+const (
+ RuntimeWebhookEventTypeAgentCreated RuntimeWebhookEventType = "agent.created"
+ RuntimeWebhookEventTypeAgentUpdated RuntimeWebhookEventType = "agent.updated"
+ RuntimeWebhookEventTypeAgentDeleted RuntimeWebhookEventType = "agent.deleted"
+ RuntimeWebhookEventTypeThreadCreated RuntimeWebhookEventType = "thread.created"
+ RuntimeWebhookEventTypeThreadStatusChanged RuntimeWebhookEventType = "thread.status.changed"
+ RuntimeWebhookEventTypeThreadCompleted RuntimeWebhookEventType = "thread.completed"
+ RuntimeWebhookEventTypeThreadFailed RuntimeWebhookEventType = "thread.failed"
+ RuntimeWebhookEventTypeTurnCreated RuntimeWebhookEventType = "turn.created"
+ RuntimeWebhookEventTypeTurnCompleted RuntimeWebhookEventType = "turn.completed"
+ RuntimeWebhookEventTypeTurnFailed RuntimeWebhookEventType = "turn.failed"
+ RuntimeWebhookEventTypeMessageCreated RuntimeWebhookEventType = "message.created"
+ RuntimeWebhookEventTypeApprovalRequested RuntimeWebhookEventType = "approval.requested"
+ RuntimeWebhookEventTypeApprovalResolved RuntimeWebhookEventType = "approval.resolved"
+ RuntimeWebhookEventTypeApprovalGranted RuntimeWebhookEventType = "approval.granted"
+ RuntimeWebhookEventTypeScheduleCreated RuntimeWebhookEventType = "schedule.created"
+ RuntimeWebhookEventTypeScheduleDeleted RuntimeWebhookEventType = "schedule.deleted"
+ RuntimeWebhookEventTypeScheduleTriggered RuntimeWebhookEventType = "schedule.triggered"
+ RuntimeWebhookEventTypeConnectionAttached RuntimeWebhookEventType = "connection.attached"
+ RuntimeWebhookEventTypeConnectionDetached RuntimeWebhookEventType = "connection.detached"
+ RuntimeWebhookEventTypeWebhookTest RuntimeWebhookEventType = "webhook.test"
+)
+
+func (r RuntimeWebhookEventType) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventTypeAgentCreated, RuntimeWebhookEventTypeAgentUpdated, RuntimeWebhookEventTypeAgentDeleted, RuntimeWebhookEventTypeThreadCreated, RuntimeWebhookEventTypeThreadStatusChanged, RuntimeWebhookEventTypeThreadCompleted, RuntimeWebhookEventTypeThreadFailed, RuntimeWebhookEventTypeTurnCreated, RuntimeWebhookEventTypeTurnCompleted, RuntimeWebhookEventTypeTurnFailed, RuntimeWebhookEventTypeMessageCreated, RuntimeWebhookEventTypeApprovalRequested, RuntimeWebhookEventTypeApprovalResolved, RuntimeWebhookEventTypeApprovalGranted, RuntimeWebhookEventTypeScheduleCreated, RuntimeWebhookEventTypeScheduleDeleted, RuntimeWebhookEventTypeScheduleTriggered, RuntimeWebhookEventTypeConnectionAttached, RuntimeWebhookEventTypeConnectionDetached, RuntimeWebhookEventTypeWebhookTest:
+ return true
+ }
+ return false
+}
+
+type SubscriptionEvent struct {
+ Event RuntimeWebhookEvent `json:"event" api:"required"`
+ Seq float64 `json:"seq" api:"required"`
+ JSON subscriptionEventJSON `json:"-"`
+}
+
+// subscriptionEventJSON contains the JSON metadata for the struct
+// [SubscriptionEvent]
+type subscriptionEventJSON struct {
+ Event apijson.Field
+ Seq apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SubscriptionEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r subscriptionEventJSON) RawJSON() string {
+ return r.raw
+}
+
+type EventListForAgentParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventListForAgentParamsHistory] `query:"history"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [EventListForAgentParams]'s query parameters as
+// `url.Values`.
+func (r EventListForAgentParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventListForAgentParamsHistory string
+
+const (
+ EventListForAgentParamsHistoryTrue EventListForAgentParamsHistory = "true"
+ EventListForAgentParamsHistoryFalse EventListForAgentParamsHistory = "false"
+)
+
+func (r EventListForAgentParamsHistory) IsKnown() bool {
+ switch r {
+ case EventListForAgentParamsHistoryTrue, EventListForAgentParamsHistoryFalse:
+ return true
+ }
+ return false
+}
+
+type EventListForFleetParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventListForFleetParamsHistory] `query:"history"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [EventListForFleetParams]'s query parameters as
+// `url.Values`.
+func (r EventListForFleetParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventListForFleetParamsHistory string
+
+const (
+ EventListForFleetParamsHistoryTrue EventListForFleetParamsHistory = "true"
+ EventListForFleetParamsHistoryFalse EventListForFleetParamsHistory = "false"
+)
+
+func (r EventListForFleetParamsHistory) IsKnown() bool {
+ switch r {
+ case EventListForFleetParamsHistoryTrue, EventListForFleetParamsHistoryFalse:
+ return true
+ }
+ return false
+}
+
+type EventListForThreadParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventListForThreadParamsHistory] `query:"history"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [EventListForThreadParams]'s query parameters as
+// `url.Values`.
+func (r EventListForThreadParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventListForThreadParamsHistory string
+
+const (
+ EventListForThreadParamsHistoryTrue EventListForThreadParamsHistory = "true"
+ EventListForThreadParamsHistoryFalse EventListForThreadParamsHistory = "false"
+)
+
+func (r EventListForThreadParamsHistory) IsKnown() bool {
+ switch r {
+ case EventListForThreadParamsHistoryTrue, EventListForThreadParamsHistoryFalse:
+ return true
+ }
+ return false
+}
diff --git a/cell_test.go b/event_test.go
similarity index 51%
rename from cell_test.go
rename to event_test.go
index 37ac422..058eff0 100644
--- a/cell_test.go
+++ b/event_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellNewWithOptionalParams(t *testing.T) {
+func TestEventListForAgentWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,26 +25,16 @@ func TestCellNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.New(context.TODO(), cercago.CellNewParams{
- UserID: cercago.F("userId"),
- Configuration: cercago.F(cercago.CellConfigurationParam{
- ApprovalRequired: cercago.F([]cercago.RuntimeToolName{cercago.RuntimeToolNameWebSearch}),
- ApprovalTimeoutMs: cercago.F(0.000000),
- DefaultModel: cercago.F("defaultModel"),
- ExcludedToolSourceIDs: cercago.F([]string{"string"}),
- Features: cercago.F([]cercago.CellConfigurationFeature{cercago.CellConfigurationFeatureMemory}),
- Instructions: cercago.F("instructions"),
- ToolApprovalOverrides: cercago.F(map[string]cercago.RuntimeToolApprovalOverrideMode{
- "foo": cercago.RuntimeToolApprovalOverrideModeAlways,
- }),
- ToolSourceMode: cercago.F(cercago.CellConfigurationToolSourceModeInherit),
- UserContext: cercago.F("userContext"),
- }),
- EnvironmentID: cercago.F("environmentId"),
- Metadata: cercago.F(cercago.CellMetadataParam{
- "project": "alpha",
- }),
- })
+ _, err := client.Events.ListForAgent(
+ context.TODO(),
+ "agent_abc123",
+ cercago.EventListForAgentParams{
+ Cursor: cercago.F("cursor_abc123"),
+ Events: cercago.F("thread.created,thread.completed"),
+ History: cercago.F(cercago.EventListForAgentParamsHistoryTrue),
+ Limit: cercago.F("20"),
+ },
+ )
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
@@ -54,7 +44,7 @@ func TestCellNewWithOptionalParams(t *testing.T) {
}
}
-func TestCellGet(t *testing.T) {
+func TestEventListForFleetWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -66,7 +56,16 @@ func TestCellGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Get(context.TODO(), "cell_abc123")
+ _, err := client.Events.ListForFleet(
+ context.TODO(),
+ "fleet_abc123",
+ cercago.EventListForFleetParams{
+ Cursor: cercago.F("cursor_abc123"),
+ Events: cercago.F("thread.created,thread.completed"),
+ History: cercago.F(cercago.EventListForFleetParamsHistoryTrue),
+ Limit: cercago.F("20"),
+ },
+ )
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
@@ -76,7 +75,7 @@ func TestCellGet(t *testing.T) {
}
}
-func TestCellUpdateWithOptionalParams(t *testing.T) {
+func TestEventListForThreadWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -88,23 +87,15 @@ func TestCellUpdateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Update(
+ _, err := client.Events.ListForThread(
context.TODO(),
- "cell_abc123",
- cercago.CellUpdateParams{
- Configuration: cercago.F(cercago.CellConfigurationParam{
- ApprovalRequired: cercago.F([]cercago.RuntimeToolName{cercago.RuntimeToolNameWebSearch}),
- ApprovalTimeoutMs: cercago.F(0.000000),
- DefaultModel: cercago.F("defaultModel"),
- ExcludedToolSourceIDs: cercago.F([]string{"string"}),
- Features: cercago.F([]cercago.CellConfigurationFeature{cercago.CellConfigurationFeatureMemory}),
- Instructions: cercago.F("instructions"),
- ToolApprovalOverrides: cercago.F(map[string]cercago.RuntimeToolApprovalOverrideMode{
- "foo": cercago.RuntimeToolApprovalOverrideModeAlways,
- }),
- ToolSourceMode: cercago.F(cercago.CellConfigurationToolSourceModeInherit),
- UserContext: cercago.F("userContext"),
- }),
+ "agent_abc123",
+ "thread_abc123",
+ cercago.EventListForThreadParams{
+ Cursor: cercago.F("cursor_abc123"),
+ Events: cercago.F("thread.created,thread.completed"),
+ History: cercago.F(cercago.EventListForThreadParamsHistoryTrue),
+ Limit: cercago.F("20"),
},
)
if err != nil {
@@ -116,7 +107,29 @@ func TestCellUpdateWithOptionalParams(t *testing.T) {
}
}
-func TestCellListWithOptionalParams(t *testing.T) {
+func TestEventSubscribeAgent(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Events.SubscribeAgent(context.TODO(), "agent_abc123")
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestEventSubscribeFleet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -128,12 +141,7 @@ func TestCellListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.List(context.TODO(), cercago.CellListParams{
- Active: cercago.F(cercago.CellListParamsActiveTrue),
- Cursor: cercago.F("cursor_abc123"),
- EnvironmentID: cercago.F("env_abc123"),
- Limit: cercago.F("20"),
- })
+ _, err := client.Events.SubscribeFleet(context.TODO(), "fleet_abc123")
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
@@ -143,7 +151,7 @@ func TestCellListWithOptionalParams(t *testing.T) {
}
}
-func TestCellDelete(t *testing.T) {
+func TestEventSubscribeThread(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -155,7 +163,11 @@ func TestCellDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Delete(context.TODO(), "cell_abc123")
+ _, err := client.Events.SubscribeThread(
+ context.TODO(),
+ "agent_abc123",
+ "thread_abc123",
+ )
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
diff --git a/fleet.go b/fleet.go
new file mode 100644
index 0000000..c28afad
--- /dev/null
+++ b/fleet.go
@@ -0,0 +1,55 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/option"
+)
+
+// FleetService contains methods and other services that help with interacting with
+// the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewFleetService] method instead.
+type FleetService struct {
+ Options []option.RequestOption
+}
+
+// NewFleetService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewFleetService(opts ...option.RequestOption) (r *FleetService) {
+ r = &FleetService{}
+ r.Options = opts
+ return
+}
+
+type Fleet struct {
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Name string `json:"name" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ JSON fleetJSON `json:"-"`
+}
+
+// fleetJSON contains the JSON metadata for the struct [Fleet]
+type fleetJSON struct {
+ ID apijson.Field
+ CreatedAt apijson.Field
+ Name apijson.Field
+ OrgID apijson.Field
+ UpdatedAt apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Fleet) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r fleetJSON) RawJSON() string {
+ return r.raw
+}
diff --git a/log.go b/log.go
new file mode 100644
index 0000000..233e4c8
--- /dev/null
+++ b/log.go
@@ -0,0 +1,179 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+)
+
+// LogService contains methods and other services that help with interacting with
+// the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewLogService] method instead.
+type LogService struct {
+ Options []option.RequestOption
+}
+
+// NewLogService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewLogService(opts ...option.RequestOption) (r *LogService) {
+ r = &LogService{}
+ r.Options = opts
+ return
+}
+
+func (r *LogService) ListForAgent(ctx context.Context, agentID string, query LogListForAgentParams, opts ...option.RequestOption) (res *pagination.LogsCursorPage[ThreadLog], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/logs", agentID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *LogService) ListForAgentAutoPaging(ctx context.Context, agentID string, query LogListForAgentParams, opts ...option.RequestOption) *pagination.LogsCursorPageAutoPager[ThreadLog] {
+ return pagination.NewLogsCursorPageAutoPager(r.ListForAgent(ctx, agentID, query, opts...))
+}
+
+func (r *LogService) ListForThread(ctx context.Context, agentID string, threadID string, query LogListForThreadParams, opts ...option.RequestOption) (res *pagination.LogsCursorPage[ThreadLog], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/logs", agentID, threadID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *LogService) ListForThreadAutoPaging(ctx context.Context, agentID string, threadID string, query LogListForThreadParams, opts ...option.RequestOption) *pagination.LogsCursorPageAutoPager[ThreadLog] {
+ return pagination.NewLogsCursorPageAutoPager(r.ListForThread(ctx, agentID, threadID, query, opts...))
+}
+
+type ThreadLog struct {
+ ID string `json:"id" api:"required"`
+ Activity string `json:"activity" api:"required,nullable"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ InputTokens float64 `json:"inputTokens" api:"required"`
+ MessageCount float64 `json:"messageCount" api:"required"`
+ NextStep string `json:"nextStep" api:"required,nullable"`
+ OutputTokens float64 `json:"outputTokens" api:"required"`
+ Status ThreadLogStatus `json:"status" api:"required"`
+ ThreadID string `json:"threadId" api:"required"`
+ TurnCompletedAt string `json:"turnCompletedAt" api:"required"`
+ TurnSeq float64 `json:"turnSeq" api:"required"`
+ JSON threadLogJSON `json:"-"`
+}
+
+// threadLogJSON contains the JSON metadata for the struct [ThreadLog]
+type threadLogJSON struct {
+ ID apijson.Field
+ Activity apijson.Field
+ CreatedAt apijson.Field
+ InputTokens apijson.Field
+ MessageCount apijson.Field
+ NextStep apijson.Field
+ OutputTokens apijson.Field
+ Status apijson.Field
+ ThreadID apijson.Field
+ TurnCompletedAt apijson.Field
+ TurnSeq apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadLog) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadLogJSON) RawJSON() string {
+ return r.raw
+}
+
+type ThreadLogStatus string
+
+const (
+ ThreadLogStatusCompleted ThreadLogStatus = "completed"
+ ThreadLogStatusFailed ThreadLogStatus = "failed"
+)
+
+func (r ThreadLogStatus) IsKnown() bool {
+ switch r {
+ case ThreadLogStatusCompleted, ThreadLogStatusFailed:
+ return true
+ }
+ return false
+}
+
+type LogListForAgentParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [LogListForAgentParams]'s query parameters as `url.Values`.
+func (r LogListForAgentParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+type LogListForThreadParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [LogListForThreadParams]'s query parameters as `url.Values`.
+func (r LogListForThreadParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
diff --git a/cellcontext_test.go b/log_test.go
similarity index 77%
rename from cellcontext_test.go
rename to log_test.go
index 9d2e5c0..ac79ff5 100644
--- a/cellcontext_test.go
+++ b/log_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellContextListWithOptionalParams(t *testing.T) {
+func TestLogListForAgentWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,13 +25,12 @@ func TestCellContextListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Context.List(
+ _, err := client.Logs.ListForAgent(
context.TODO(),
- "cell_abc123",
- cercago.CellContextListParams{
+ "agent_abc123",
+ cercago.LogListForAgentParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
- Prefix: cercago.F("notes/"),
},
)
if err != nil {
@@ -43,7 +42,7 @@ func TestCellContextListWithOptionalParams(t *testing.T) {
}
}
-func TestCellContextSearchWithOptionalParams(t *testing.T) {
+func TestLogListForThreadWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -55,14 +54,13 @@ func TestCellContextSearchWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Context.Search(
+ _, err := client.Logs.ListForThread(
context.TODO(),
- "cell_abc123",
- cercago.CellContextSearchParams{
- Q: cercago.F("project notes"),
+ "agent_abc123",
+ "thread_abc123",
+ cercago.LogListForThreadParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
- Prefix: cercago.F("notes/"),
},
)
if err != nil {
diff --git a/oauth_test.go b/oauth_test.go
index 95c068d..59789fb 100644
--- a/oauth_test.go
+++ b/oauth_test.go
@@ -30,7 +30,7 @@ func TestOAuthConnectWithOptionalParams(t *testing.T) {
"google",
cercago.OAuthConnectParams{
ReturnOrigin: cercago.F("https://app.example.com"),
- Scope: cercago.F("env:org_abc123:env_abc123"),
+ Scope: cercago.F("env:org_abc123:fleet_abc123"),
Scopes: cercago.F([]string{"email", "profile"}),
},
)
diff --git a/packages/pagination/pagination.go b/packages/pagination/pagination.go
index 6778d4b..9230200 100644
--- a/packages/pagination/pagination.go
+++ b/packages/pagination/pagination.go
@@ -10,35 +10,38 @@ import (
"github.com/matrices/cerca-go/option"
)
-type CursorPage[T any] struct {
- Cursor string `json:"cursor" api:"nullable"`
- HasMore bool `json:"has_more"`
- JSON cursorPageJSON `json:"-"`
+type AgentsCursorPage[T any] struct {
+ Agents []T `json:"agents"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON agentsCursorPageJSON `json:"-"`
cfg *requestconfig.RequestConfig
res *http.Response
}
-// cursorPageJSON contains the JSON metadata for the struct [CursorPage[T]]
-type cursorPageJSON struct {
+// agentsCursorPageJSON contains the JSON metadata for the struct
+// [AgentsCursorPage[T]]
+type agentsCursorPageJSON struct {
+ Agents apijson.Field
Cursor apijson.Field
HasMore apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *CursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+func (r *AgentsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r cursorPageJSON) RawJSON() string {
+func (r agentsCursorPageJSON) RawJSON() string {
return r.raw
}
// GetNextPage returns the next page as defined by this pagination style. When
// there is no next page, this function will return a 'nil' for the page value, but
// will not return an error
-func (r *CursorPage[T]) GetNextPage() (res *CursorPage[T], err error) {
- if len(r.data) == 0 {
+func (r *AgentsCursorPage[T]) GetNextPage() (res *AgentsCursorPage[T], err error) {
+ if len(r.Agents) == 0 {
return nil, nil
}
@@ -65,54 +68,1263 @@ func (r *CursorPage[T]) GetNextPage() (res *CursorPage[T], err error) {
return res, nil
}
-func (r *CursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+func (r *AgentsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
if r == nil {
- r = &CursorPage[T]{}
+ r = &AgentsCursorPage[T]{}
}
r.cfg = cfg
r.res = res
}
-type CursorPageAutoPager[T any] struct {
- page *CursorPage[T]
+type AgentsCursorPageAutoPager[T any] struct {
+ page *AgentsCursorPage[T]
cur T
idx int
run int
err error
}
-func NewCursorPageAutoPager[T any](page *CursorPage[T], err error) *CursorPageAutoPager[T] {
- return &CursorPageAutoPager[T]{
+func NewAgentsCursorPageAutoPager[T any](page *AgentsCursorPage[T], err error) *AgentsCursorPageAutoPager[T] {
+ return &AgentsCursorPageAutoPager[T]{
page: page,
err: err,
}
}
-func (r *CursorPageAutoPager[T]) Next() bool {
- if r.page == nil || len(r.page.data) == 0 {
+func (r *AgentsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Agents) == 0 {
return false
}
- if r.idx >= len(r.page.data) {
+ if r.idx >= len(r.page.Agents) {
r.idx = 0
r.page, r.err = r.page.GetNextPage()
- if r.err != nil || r.page == nil || len(r.page.data) == 0 {
+ if r.err != nil || r.page == nil || len(r.page.Agents) == 0 {
return false
}
}
- r.cur = r.page.data[r.idx]
+ r.cur = r.page.Agents[r.idx]
r.run += 1
r.idx += 1
return true
}
-func (r *CursorPageAutoPager[T]) Current() T {
+func (r *AgentsCursorPageAutoPager[T]) Current() T {
return r.cur
}
-func (r *CursorPageAutoPager[T]) Err() error {
+func (r *AgentsCursorPageAutoPager[T]) Err() error {
return r.err
}
-func (r *CursorPageAutoPager[T]) Index() int {
+func (r *AgentsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type ApprovalsCursorPage[T any] struct {
+ Approvals []T `json:"approvals"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON approvalsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// approvalsCursorPageJSON contains the JSON metadata for the struct
+// [ApprovalsCursorPage[T]]
+type approvalsCursorPageJSON struct {
+ Approvals apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ApprovalsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r approvalsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *ApprovalsCursorPage[T]) GetNextPage() (res *ApprovalsCursorPage[T], err error) {
+ if len(r.Approvals) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ApprovalsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &ApprovalsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type ApprovalsCursorPageAutoPager[T any] struct {
+ page *ApprovalsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewApprovalsCursorPageAutoPager[T any](page *ApprovalsCursorPage[T], err error) *ApprovalsCursorPageAutoPager[T] {
+ return &ApprovalsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *ApprovalsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Approvals) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Approvals) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Approvals) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Approvals[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *ApprovalsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *ApprovalsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *ApprovalsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type ConnectionsCursorPage[T any] struct {
+ Connections []T `json:"connections"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON connectionsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// connectionsCursorPageJSON contains the JSON metadata for the struct
+// [ConnectionsCursorPage[T]]
+type connectionsCursorPageJSON struct {
+ Connections apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConnectionsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r connectionsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *ConnectionsCursorPage[T]) GetNextPage() (res *ConnectionsCursorPage[T], err error) {
+ if len(r.Connections) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ConnectionsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &ConnectionsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type ConnectionsCursorPageAutoPager[T any] struct {
+ page *ConnectionsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewConnectionsCursorPageAutoPager[T any](page *ConnectionsCursorPage[T], err error) *ConnectionsCursorPageAutoPager[T] {
+ return &ConnectionsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *ConnectionsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Connections) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Connections) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Connections) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Connections[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *ConnectionsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *ConnectionsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *ConnectionsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type EntriesCursorPage[T any] struct {
+ Entries []T `json:"entries"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON entriesCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// entriesCursorPageJSON contains the JSON metadata for the struct
+// [EntriesCursorPage[T]]
+type entriesCursorPageJSON struct {
+ Entries apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *EntriesCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r entriesCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *EntriesCursorPage[T]) GetNextPage() (res *EntriesCursorPage[T], err error) {
+ if len(r.Entries) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *EntriesCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &EntriesCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type EntriesCursorPageAutoPager[T any] struct {
+ page *EntriesCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewEntriesCursorPageAutoPager[T any](page *EntriesCursorPage[T], err error) *EntriesCursorPageAutoPager[T] {
+ return &EntriesCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *EntriesCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Entries) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Entries) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Entries) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Entries[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *EntriesCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *EntriesCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *EntriesCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type EventsCursorPage[T any] struct {
+ Events []T `json:"events"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON eventsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// eventsCursorPageJSON contains the JSON metadata for the struct
+// [EventsCursorPage[T]]
+type eventsCursorPageJSON struct {
+ Events apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *EventsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r eventsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *EventsCursorPage[T]) GetNextPage() (res *EventsCursorPage[T], err error) {
+ if len(r.Events) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *EventsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &EventsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type EventsCursorPageAutoPager[T any] struct {
+ page *EventsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewEventsCursorPageAutoPager[T any](page *EventsCursorPage[T], err error) *EventsCursorPageAutoPager[T] {
+ return &EventsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *EventsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Events) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Events) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Events) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Events[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *EventsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *EventsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *EventsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type FleetsCursorPage[T any] struct {
+ Fleets []T `json:"fleets"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON fleetsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// fleetsCursorPageJSON contains the JSON metadata for the struct
+// [FleetsCursorPage[T]]
+type fleetsCursorPageJSON struct {
+ Fleets apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *FleetsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r fleetsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *FleetsCursorPage[T]) GetNextPage() (res *FleetsCursorPage[T], err error) {
+ if len(r.Fleets) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *FleetsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &FleetsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type FleetsCursorPageAutoPager[T any] struct {
+ page *FleetsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewFleetsCursorPageAutoPager[T any](page *FleetsCursorPage[T], err error) *FleetsCursorPageAutoPager[T] {
+ return &FleetsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *FleetsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Fleets) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Fleets) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Fleets) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Fleets[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *FleetsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *FleetsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *FleetsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type GrantsCursorPage[T any] struct {
+ Grants []T `json:"grants"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON grantsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// grantsCursorPageJSON contains the JSON metadata for the struct
+// [GrantsCursorPage[T]]
+type grantsCursorPageJSON struct {
+ Grants apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *GrantsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r grantsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *GrantsCursorPage[T]) GetNextPage() (res *GrantsCursorPage[T], err error) {
+ if len(r.Grants) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *GrantsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &GrantsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type GrantsCursorPageAutoPager[T any] struct {
+ page *GrantsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewGrantsCursorPageAutoPager[T any](page *GrantsCursorPage[T], err error) *GrantsCursorPageAutoPager[T] {
+ return &GrantsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *GrantsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Grants) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Grants) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Grants) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Grants[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *GrantsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *GrantsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *GrantsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type LogsCursorPage[T any] struct {
+ Logs []T `json:"logs"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON logsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// logsCursorPageJSON contains the JSON metadata for the struct [LogsCursorPage[T]]
+type logsCursorPageJSON struct {
+ Logs apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *LogsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r logsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *LogsCursorPage[T]) GetNextPage() (res *LogsCursorPage[T], err error) {
+ if len(r.Logs) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *LogsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &LogsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type LogsCursorPageAutoPager[T any] struct {
+ page *LogsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewLogsCursorPageAutoPager[T any](page *LogsCursorPage[T], err error) *LogsCursorPageAutoPager[T] {
+ return &LogsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *LogsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Logs) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Logs) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Logs) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Logs[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *LogsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *LogsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *LogsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type ResultsCursorPage[T any] struct {
+ Results []T `json:"results"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON resultsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// resultsCursorPageJSON contains the JSON metadata for the struct
+// [ResultsCursorPage[T]]
+type resultsCursorPageJSON struct {
+ Results apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ResultsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r resultsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *ResultsCursorPage[T]) GetNextPage() (res *ResultsCursorPage[T], err error) {
+ if len(r.Results) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ResultsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &ResultsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type ResultsCursorPageAutoPager[T any] struct {
+ page *ResultsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewResultsCursorPageAutoPager[T any](page *ResultsCursorPage[T], err error) *ResultsCursorPageAutoPager[T] {
+ return &ResultsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *ResultsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Results) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Results) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Results) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Results[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *ResultsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *ResultsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *ResultsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type SourcesCursorPage[T any] struct {
+ Sources []T `json:"sources"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON sourcesCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// sourcesCursorPageJSON contains the JSON metadata for the struct
+// [SourcesCursorPage[T]]
+type sourcesCursorPageJSON struct {
+ Sources apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SourcesCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r sourcesCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *SourcesCursorPage[T]) GetNextPage() (res *SourcesCursorPage[T], err error) {
+ if len(r.Sources) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *SourcesCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &SourcesCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type SourcesCursorPageAutoPager[T any] struct {
+ page *SourcesCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewSourcesCursorPageAutoPager[T any](page *SourcesCursorPage[T], err error) *SourcesCursorPageAutoPager[T] {
+ return &SourcesCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *SourcesCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Sources) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Sources) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Sources) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Sources[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *SourcesCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *SourcesCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *SourcesCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type SubscriptionsCursorPage[T any] struct {
+ Subscriptions []T `json:"subscriptions"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON subscriptionsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// subscriptionsCursorPageJSON contains the JSON metadata for the struct
+// [SubscriptionsCursorPage[T]]
+type subscriptionsCursorPageJSON struct {
+ Subscriptions apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SubscriptionsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r subscriptionsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *SubscriptionsCursorPage[T]) GetNextPage() (res *SubscriptionsCursorPage[T], err error) {
+ if len(r.Subscriptions) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *SubscriptionsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &SubscriptionsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type SubscriptionsCursorPageAutoPager[T any] struct {
+ page *SubscriptionsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewSubscriptionsCursorPageAutoPager[T any](page *SubscriptionsCursorPage[T], err error) *SubscriptionsCursorPageAutoPager[T] {
+ return &SubscriptionsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *SubscriptionsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Subscriptions) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Subscriptions) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Subscriptions) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Subscriptions[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *SubscriptionsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *SubscriptionsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *SubscriptionsCursorPageAutoPager[T]) Index() int {
+ return r.run
+}
+
+type ThreadsCursorPage[T any] struct {
+ Threads []T `json:"threads"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON threadsCursorPageJSON `json:"-"`
+ cfg *requestconfig.RequestConfig
+ res *http.Response
+}
+
+// threadsCursorPageJSON contains the JSON metadata for the struct
+// [ThreadsCursorPage[T]]
+type threadsCursorPageJSON struct {
+ Threads apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadsCursorPageJSON) RawJSON() string {
+ return r.raw
+}
+
+// GetNextPage returns the next page as defined by this pagination style. When
+// there is no next page, this function will return a 'nil' for the page value, but
+// will not return an error
+func (r *ThreadsCursorPage[T]) GetNextPage() (res *ThreadsCursorPage[T], err error) {
+ if len(r.Threads) == 0 {
+ return nil, nil
+ }
+
+ if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
+ return nil, nil
+ }
+ next := r.Cursor
+ if len(next) == 0 {
+ return nil, nil
+ }
+ cfg := r.cfg.Clone(r.cfg.Context)
+ err = cfg.Apply(option.WithQuery("cursor", next))
+ if err != nil {
+ return nil, err
+ }
+ var raw *http.Response
+ cfg.ResponseInto = &raw
+ cfg.ResponseBodyInto = &res
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ThreadsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &ThreadsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type ThreadsCursorPageAutoPager[T any] struct {
+ page *ThreadsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewThreadsCursorPageAutoPager[T any](page *ThreadsCursorPage[T], err error) *ThreadsCursorPageAutoPager[T] {
+ return &ThreadsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *ThreadsCursorPageAutoPager[T]) Next() bool {
+ if r.page == nil || len(r.page.Threads) == 0 {
+ return false
+ }
+ if r.idx >= len(r.page.Threads) {
+ r.idx = 0
+ r.page, r.err = r.page.GetNextPage()
+ if r.err != nil || r.page == nil || len(r.page.Threads) == 0 {
+ return false
+ }
+ }
+ r.cur = r.page.Threads[r.idx]
+ r.run += 1
+ r.idx += 1
+ return true
+}
+
+func (r *ThreadsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *ThreadsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *ThreadsCursorPageAutoPager[T]) Index() int {
return r.run
}
diff --git a/celltoolsource_test.go b/paginationauto_test.go
similarity index 65%
rename from celltoolsource_test.go
rename to paginationauto_test.go
index b6629b2..4453352 100644
--- a/celltoolsource_test.go
+++ b/paginationauto_test.go
@@ -4,7 +4,6 @@ package cercago_test
import (
"context"
- "errors"
"os"
"testing"
@@ -13,7 +12,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellToolSourceList(t *testing.T) {
+func TestAutoPagination(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,12 +24,13 @@ func TestCellToolSourceList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.ToolSources.List(context.TODO(), "cell_abc123")
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
+ iter := client.Agents.ListAutoPaging(context.TODO(), cercago.AgentListParams{})
+ // The mock server isn't going to give us real pagination
+ for i := 0; i < 3 && iter.Next(); i++ {
+ agent := iter.Current()
+ t.Logf("%+v\n", agent.ID)
+ }
+ if err := iter.Err(); err != nil {
t.Fatalf("err should be nil: %s", err.Error())
}
}
diff --git a/cellmetadata_test.go b/paginationmanual_test.go
similarity index 58%
rename from cellmetadata_test.go
rename to paginationmanual_test.go
index 41b230a..822e322 100644
--- a/cellmetadata_test.go
+++ b/paginationmanual_test.go
@@ -4,7 +4,6 @@ package cercago_test
import (
"context"
- "errors"
"os"
"testing"
@@ -13,7 +12,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellMetadataUpdate(t *testing.T) {
+func TestManualPagination(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,20 +24,21 @@ func TestCellMetadataUpdate(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Metadata.Update(
- context.TODO(),
- "cell_abc123",
- cercago.CellMetadataUpdateParams{
- Metadata: cercago.F(cercago.CellMetadataParam{
- "project": "alpha",
- }),
- },
- )
+ page, err := client.Agents.List(context.TODO(), cercago.AgentListParams{})
+ if err != nil {
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+ for _, agent := range page.Agents {
+ t.Logf("%+v\n", agent.ID)
+ }
+ // The mock server isn't going to give us real pagination
+ page, err = page.GetNextPage()
if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
t.Fatalf("err should be nil: %s", err.Error())
}
+ if page != nil {
+ for _, agent := range page.Agents {
+ t.Logf("%+v\n", agent.ID)
+ }
+ }
}
diff --git a/sandbox.go b/sandbox.go
new file mode 100644
index 0000000..460b0e5
--- /dev/null
+++ b/sandbox.go
@@ -0,0 +1,204 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+)
+
+// SandboxService contains methods and other services that help with interacting
+// with the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewSandboxService] method instead.
+type SandboxService struct {
+ Options []option.RequestOption
+}
+
+// NewSandboxService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewSandboxService(opts ...option.RequestOption) (r *SandboxService) {
+ r = &SandboxService{}
+ r.Options = opts
+ return
+}
+
+func (r *SandboxService) Exec(ctx context.Context, agentID string, body SandboxExecParams, opts ...option.RequestOption) (res *ExecResult, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/sandbox/exec", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *SandboxService) Read(ctx context.Context, agentID string, body SandboxReadParams, opts ...option.RequestOption) (res *ReadResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/sandbox/read", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *SandboxService) Write(ctx context.Context, agentID string, body SandboxWriteParams, opts ...option.RequestOption) (res *SandboxWriteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/sandbox/write", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+type ExecResult struct {
+ ExitCode float64 `json:"exitCode" api:"required,nullable"`
+ Handle string `json:"handle" api:"required"`
+ State ExecResultState `json:"state" api:"required"`
+ Stderr string `json:"stderr" api:"required"`
+ StderrOffset float64 `json:"stderrOffset" api:"required"`
+ Stdout string `json:"stdout" api:"required"`
+ StdoutOffset float64 `json:"stdoutOffset" api:"required"`
+ JSON execResultJSON `json:"-"`
+}
+
+// execResultJSON contains the JSON metadata for the struct [ExecResult]
+type execResultJSON struct {
+ ExitCode apijson.Field
+ Handle apijson.Field
+ State apijson.Field
+ Stderr apijson.Field
+ StderrOffset apijson.Field
+ Stdout apijson.Field
+ StdoutOffset apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ExecResult) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r execResultJSON) RawJSON() string {
+ return r.raw
+}
+
+type ExecResultState string
+
+const (
+ ExecResultStateRunning ExecResultState = "running"
+ ExecResultStateExited ExecResultState = "exited"
+)
+
+func (r ExecResultState) IsKnown() bool {
+ switch r {
+ case ExecResultStateRunning, ExecResultStateExited:
+ return true
+ }
+ return false
+}
+
+type ReadResponse struct {
+ BytesRead float64 `json:"bytesRead" api:"required"`
+ Content string `json:"content" api:"required"`
+ JSON readResponseJSON `json:"-"`
+}
+
+// readResponseJSON contains the JSON metadata for the struct [ReadResponse]
+type readResponseJSON struct {
+ BytesRead apijson.Field
+ Content apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ReadResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r readResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type SandboxWriteResponse struct {
+ Success SandboxWriteResponseSuccess `json:"success" api:"required"`
+ JSON sandboxWriteResponseJSON `json:"-"`
+}
+
+// sandboxWriteResponseJSON contains the JSON metadata for the struct
+// [SandboxWriteResponse]
+type sandboxWriteResponseJSON struct {
+ Success apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SandboxWriteResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r sandboxWriteResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type SandboxWriteResponseSuccess bool
+
+const (
+ SandboxWriteResponseSuccessTrue SandboxWriteResponseSuccess = true
+)
+
+func (r SandboxWriteResponseSuccess) IsKnown() bool {
+ switch r {
+ case SandboxWriteResponseSuccessTrue:
+ return true
+ }
+ return false
+}
+
+type SandboxExecParams struct {
+ Command param.Field[string] `json:"command" api:"required"`
+ MaxBuffer param.Field[float64] `json:"maxBuffer"`
+ // Timeout in seconds. Runtime converts this to milliseconds.
+ ExecutionTimeout param.Field[float64] `json:"timeout"`
+ // Optional sandbox working directory.
+ Workdir param.Field[string] `json:"workdir"`
+}
+
+func (r SandboxExecParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type SandboxReadParams struct {
+ Path param.Field[string] `json:"path" api:"required"`
+ Limit param.Field[float64] `json:"limit"`
+ Offset param.Field[float64] `json:"offset"`
+}
+
+func (r SandboxReadParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type SandboxWriteParams struct {
+ Content param.Field[string] `json:"content" api:"required"`
+ Path param.Field[string] `json:"path" api:"required"`
+}
+
+func (r SandboxWriteParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/cellsandbox_test.go b/sandbox_test.go
similarity index 76%
rename from cellsandbox_test.go
rename to sandbox_test.go
index 352272c..5c57e93 100644
--- a/cellsandbox_test.go
+++ b/sandbox_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellSandboxExecWithOptionalParams(t *testing.T) {
+func TestSandboxExecWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,14 +25,14 @@ func TestCellSandboxExecWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Sandbox.Exec(
+ _, err := client.Sandbox.Exec(
context.TODO(),
- "cell_abc123",
- cercago.CellSandboxExecParams{
- Command: cercago.F("command"),
- MaxBuffer: cercago.F(0.000000),
- Timeout: cercago.F(30.000000),
- Workdir: cercago.F("/home/user"),
+ "agent_abc123",
+ cercago.SandboxExecParams{
+ Command: cercago.F("command"),
+ MaxBuffer: cercago.F(0.000000),
+ ExecutionTimeout: cercago.F(30.000000),
+ Workdir: cercago.F("/home/user"),
},
)
if err != nil {
@@ -44,7 +44,7 @@ func TestCellSandboxExecWithOptionalParams(t *testing.T) {
}
}
-func TestCellSandboxReadWithOptionalParams(t *testing.T) {
+func TestSandboxReadWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -56,10 +56,10 @@ func TestCellSandboxReadWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Sandbox.Read(
+ _, err := client.Sandbox.Read(
context.TODO(),
- "cell_abc123",
- cercago.CellSandboxReadParams{
+ "agent_abc123",
+ cercago.SandboxReadParams{
Path: cercago.F("path"),
Limit: cercago.F(0.000000),
Offset: cercago.F(0.000000),
@@ -74,7 +74,7 @@ func TestCellSandboxReadWithOptionalParams(t *testing.T) {
}
}
-func TestCellSandboxWrite(t *testing.T) {
+func TestSandboxWrite(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -86,10 +86,10 @@ func TestCellSandboxWrite(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Sandbox.Write(
+ _, err := client.Sandbox.Write(
context.TODO(),
- "cell_abc123",
- cercago.CellSandboxWriteParams{
+ "agent_abc123",
+ cercago.SandboxWriteParams{
Content: cercago.F("content"),
Path: cercago.F("path"),
},
diff --git a/schedule.go b/schedule.go
new file mode 100644
index 0000000..1fa5ced
--- /dev/null
+++ b/schedule.go
@@ -0,0 +1,251 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/shared"
+)
+
+// ScheduleService contains methods and other services that help with interacting
+// with the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewScheduleService] method instead.
+type ScheduleService struct {
+ Options []option.RequestOption
+}
+
+// NewScheduleService generates a new service that applies the given options to
+// each request. These options are applied after the parent client's options (if
+// there is one), and before any request-specific options.
+func NewScheduleService(opts ...option.RequestOption) (r *ScheduleService) {
+ r = &ScheduleService{}
+ r.Options = opts
+ return
+}
+
+func (r *ScheduleService) New(ctx context.Context, agentID string, body ScheduleNewParams, opts ...option.RequestOption) (res *ScheduledThread, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/schedules", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *ScheduleService) Update(ctx context.Context, agentID string, scheduleID string, body ScheduleUpdateParams, opts ...option.RequestOption) (res *ScheduledThread, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if scheduleID == "" {
+ err = errors.New("missing required scheduleId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/schedules/%s", agentID, scheduleID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *ScheduleService) List(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ScheduleListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/schedules", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *ScheduleService) Delete(ctx context.Context, agentID string, scheduleID string, opts ...option.RequestOption) (res *ScheduleDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if scheduleID == "" {
+ err = errors.New("missing required scheduleId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/schedules/%s", agentID, scheduleID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *ScheduleService) Trigger(ctx context.Context, agentID string, scheduleID string, opts ...option.RequestOption) (res *ScheduleTriggerResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if scheduleID == "" {
+ err = errors.New("missing required scheduleId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/schedules/%s/trigger", agentID, scheduleID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
+ return res, err
+}
+
+type ScheduledThread struct {
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Cron string `json:"cron" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ Name string `json:"name" api:"required"`
+ NextAt string `json:"nextAt" api:"required,nullable"`
+ Prompt string `json:"prompt" api:"required"`
+ Timezone string `json:"timezone" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Instructions string `json:"instructions"`
+ Model string `json:"model"`
+ Tools []shared.ToolSpec `json:"tools"`
+ JSON scheduledThreadJSON `json:"-"`
+}
+
+// scheduledThreadJSON contains the JSON metadata for the struct [ScheduledThread]
+type scheduledThreadJSON struct {
+ ID apijson.Field
+ CreatedAt apijson.Field
+ Cron apijson.Field
+ Enabled apijson.Field
+ Name apijson.Field
+ NextAt apijson.Field
+ Prompt apijson.Field
+ Timezone apijson.Field
+ UpdatedAt apijson.Field
+ Instructions apijson.Field
+ Model apijson.Field
+ Tools apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ScheduledThread) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r scheduledThreadJSON) RawJSON() string {
+ return r.raw
+}
+
+type ScheduleListResponse struct {
+ Schedules []ScheduledThread `json:"schedules" api:"required"`
+ JSON scheduleListResponseJSON `json:"-"`
+}
+
+// scheduleListResponseJSON contains the JSON metadata for the struct
+// [ScheduleListResponse]
+type scheduleListResponseJSON struct {
+ Schedules apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ScheduleListResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r scheduleListResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ScheduleDeleteResponse struct {
+ Success ScheduleDeleteResponseSuccess `json:"success" api:"required"`
+ JSON scheduleDeleteResponseJSON `json:"-"`
+}
+
+// scheduleDeleteResponseJSON contains the JSON metadata for the struct
+// [ScheduleDeleteResponse]
+type scheduleDeleteResponseJSON struct {
+ Success apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ScheduleDeleteResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r scheduleDeleteResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ScheduleDeleteResponseSuccess bool
+
+const (
+ ScheduleDeleteResponseSuccessTrue ScheduleDeleteResponseSuccess = true
+)
+
+func (r ScheduleDeleteResponseSuccess) IsKnown() bool {
+ switch r {
+ case ScheduleDeleteResponseSuccessTrue:
+ return true
+ }
+ return false
+}
+
+type ScheduleTriggerResponse struct {
+ ThreadID string `json:"threadId" api:"required"`
+ JSON scheduleTriggerResponseJSON `json:"-"`
+}
+
+// scheduleTriggerResponseJSON contains the JSON metadata for the struct
+// [ScheduleTriggerResponse]
+type scheduleTriggerResponseJSON struct {
+ ThreadID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ScheduleTriggerResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r scheduleTriggerResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ScheduleNewParams struct {
+ Cron param.Field[string] `json:"cron" api:"required"`
+ Name param.Field[string] `json:"name" api:"required"`
+ Prompt param.Field[string] `json:"prompt" api:"required"`
+ Instructions param.Field[string] `json:"instructions"`
+ Model param.Field[string] `json:"model"`
+ Timezone param.Field[string] `json:"timezone"`
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+}
+
+func (r ScheduleNewParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type ScheduleUpdateParams struct {
+ Cron param.Field[string] `json:"cron"`
+ Enabled param.Field[bool] `json:"enabled"`
+ Instructions param.Field[string] `json:"instructions"`
+ Model param.Field[string] `json:"model"`
+ Name param.Field[string] `json:"name"`
+ Prompt param.Field[string] `json:"prompt"`
+ Timezone param.Field[string] `json:"timezone"`
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+}
+
+func (r ScheduleUpdateParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/cellschedule_test.go b/schedule_test.go
similarity index 78%
rename from cellschedule_test.go
rename to schedule_test.go
index 38fcb78..d40551d 100644
--- a/cellschedule_test.go
+++ b/schedule_test.go
@@ -11,9 +11,10 @@ import (
"github.com/matrices/cerca-go"
"github.com/matrices/cerca-go/internal/testutil"
"github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/shared"
)
-func TestCellScheduleNewWithOptionalParams(t *testing.T) {
+func TestScheduleNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,17 +26,17 @@ func TestCellScheduleNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Schedules.New(
+ _, err := client.Schedules.New(
context.TODO(),
- "cell_abc123",
- cercago.CellScheduleNewParams{
+ "agent_abc123",
+ cercago.ScheduleNewParams{
Cron: cercago.F("cron"),
Name: cercago.F("name"),
Prompt: cercago.F("prompt"),
- Features: cercago.F([]cercago.CellScheduleNewParamsFeature{cercago.CellScheduleNewParamsFeatureMemory}),
Instructions: cercago.F("instructions"),
Model: cercago.F("model"),
Timezone: cercago.F("timezone"),
+ Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
},
)
if err != nil {
@@ -47,7 +48,7 @@ func TestCellScheduleNewWithOptionalParams(t *testing.T) {
}
}
-func TestCellScheduleUpdateWithOptionalParams(t *testing.T) {
+func TestScheduleUpdateWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -59,19 +60,19 @@ func TestCellScheduleUpdateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Schedules.Update(
+ _, err := client.Schedules.Update(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"schedule_abc123",
- cercago.CellScheduleUpdateParams{
+ cercago.ScheduleUpdateParams{
Cron: cercago.F("cron"),
Enabled: cercago.F(true),
- Features: cercago.F([]cercago.CellScheduleUpdateParamsFeature{cercago.CellScheduleUpdateParamsFeatureMemory}),
Instructions: cercago.F("instructions"),
Model: cercago.F("model"),
Name: cercago.F("name"),
Prompt: cercago.F("prompt"),
Timezone: cercago.F("timezone"),
+ Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
},
)
if err != nil {
@@ -83,7 +84,7 @@ func TestCellScheduleUpdateWithOptionalParams(t *testing.T) {
}
}
-func TestCellScheduleList(t *testing.T) {
+func TestScheduleList(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -95,7 +96,7 @@ func TestCellScheduleList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Schedules.List(context.TODO(), "cell_abc123")
+ _, err := client.Schedules.List(context.TODO(), "agent_abc123")
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
@@ -105,7 +106,7 @@ func TestCellScheduleList(t *testing.T) {
}
}
-func TestCellScheduleDelete(t *testing.T) {
+func TestScheduleDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -117,9 +118,9 @@ func TestCellScheduleDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Schedules.Delete(
+ _, err := client.Schedules.Delete(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"schedule_abc123",
)
if err != nil {
@@ -131,7 +132,7 @@ func TestCellScheduleDelete(t *testing.T) {
}
}
-func TestCellScheduleTrigger(t *testing.T) {
+func TestScheduleTrigger(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -143,9 +144,9 @@ func TestCellScheduleTrigger(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Schedules.Trigger(
+ _, err := client.Schedules.Trigger(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"schedule_abc123",
)
if err != nil {
diff --git a/shared/shared.go b/shared/shared.go
new file mode 100644
index 0000000..46ae0a7
--- /dev/null
+++ b/shared/shared.go
@@ -0,0 +1,98 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package shared
+
+import (
+ "github.com/matrices/cerca-go/internal/apijson"
+)
+
+type ApprovalMode string
+
+const (
+ ApprovalModeAlways ApprovalMode = "always"
+ ApprovalModeNever ApprovalMode = "never"
+)
+
+func (r ApprovalMode) IsKnown() bool {
+ switch r {
+ case ApprovalModeAlways, ApprovalModeNever:
+ return true
+ }
+ return false
+}
+
+type ErrorResponse struct {
+ Error string `json:"error" api:"required"`
+ JSON errorResponseJSON `json:"-"`
+}
+
+// errorResponseJSON contains the JSON metadata for the struct [ErrorResponse]
+type errorResponseJSON struct {
+ Error apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ErrorResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r errorResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type JsonObject map[string]interface{}
+
+type ToolName string
+
+const (
+ ToolNameGetTime ToolName = "get_time"
+ ToolNameSubThread ToolName = "sub_thread"
+ ToolNameWait ToolName = "wait"
+ ToolNameToolCall ToolName = "tool.call"
+ ToolNameToolDiscover ToolName = "tool.discover"
+ ToolNameArtifactRead ToolName = "artifact.read"
+ ToolNameAgentThreadsList ToolName = "agent.threads.list"
+ ToolNameAgentThreadsGet ToolName = "agent.threads.get"
+ ToolNameAgentApprovalsCancel ToolName = "agent.approvals.cancel"
+ ToolNameAgentApprovalsGrantThread ToolName = "agent.approvals.grant_thread"
+ ToolNameAgentApprovalsGrantAgent ToolName = "agent.approvals.grant_agent"
+ ToolNameAgentCreate ToolName = "agent.create"
+ ToolNameAgentApprovalsUpdate ToolName = "agent.approvals.update"
+ ToolNameToolConnect ToolName = "tool.connect"
+ ToolNameSandboxExec ToolName = "sandbox.exec"
+ ToolNameSandboxRead ToolName = "sandbox.read"
+ ToolNameSandboxWriteFile ToolName = "sandbox.write_file"
+ ToolNameSandboxReadFile ToolName = "sandbox.read_file"
+ ToolNameSandboxSpawn ToolName = "sandbox.spawn"
+ ToolNameSandboxStdin ToolName = "sandbox.stdin"
+ ToolNameSandboxSessionRead ToolName = "sandbox.session_read"
+ ToolNameSandboxKill ToolName = "sandbox.kill"
+ ToolNameSandboxListSessions ToolName = "sandbox.list_sessions"
+ ToolNameSandboxSyncArtifact ToolName = "sandbox.sync_artifact"
+ ToolNameMemoryRead ToolName = "memory.read"
+ ToolNameMemoryList ToolName = "memory.list"
+ ToolNameMemorySearch ToolName = "memory.search"
+ ToolNameMemoryWrite ToolName = "memory.write"
+ ToolNameMemoryDelete ToolName = "memory.delete"
+ ToolNameDBQuery ToolName = "db.query"
+ ToolNameWebSearch ToolName = "web.search"
+ ToolNameWebFetch ToolName = "web.fetch"
+ ToolNameAgentScheduleList ToolName = "agent.schedule.list"
+ ToolNameAgentScheduleCreate ToolName = "agent.schedule.create"
+ ToolNameAgentScheduleUpdate ToolName = "agent.schedule.update"
+ ToolNameAgentScheduleDelete ToolName = "agent.schedule.delete"
+ ToolNameAgentScheduleTrigger ToolName = "agent.schedule.trigger"
+)
+
+func (r ToolName) IsKnown() bool {
+ switch r {
+ case ToolNameGetTime, ToolNameSubThread, ToolNameWait, ToolNameToolCall, ToolNameToolDiscover, ToolNameArtifactRead, ToolNameAgentThreadsList, ToolNameAgentThreadsGet, ToolNameAgentApprovalsCancel, ToolNameAgentApprovalsGrantThread, ToolNameAgentApprovalsGrantAgent, ToolNameAgentCreate, ToolNameAgentApprovalsUpdate, ToolNameToolConnect, ToolNameSandboxExec, ToolNameSandboxRead, ToolNameSandboxWriteFile, ToolNameSandboxReadFile, ToolNameSandboxSpawn, ToolNameSandboxStdin, ToolNameSandboxSessionRead, ToolNameSandboxKill, ToolNameSandboxListSessions, ToolNameSandboxSyncArtifact, ToolNameMemoryRead, ToolNameMemoryList, ToolNameMemorySearch, ToolNameMemoryWrite, ToolNameMemoryDelete, ToolNameDBQuery, ToolNameWebSearch, ToolNameWebFetch, ToolNameAgentScheduleList, ToolNameAgentScheduleCreate, ToolNameAgentScheduleUpdate, ToolNameAgentScheduleDelete, ToolNameAgentScheduleTrigger:
+ return true
+ }
+ return false
+}
+
+type ToolSpec = string
+
+type ToolSpecParam = string
diff --git a/thread.go b/thread.go
new file mode 100644
index 0000000..3b577b8
--- /dev/null
+++ b/thread.go
@@ -0,0 +1,725 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "reflect"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+ "github.com/matrices/cerca-go/shared"
+ "github.com/tidwall/gjson"
+)
+
+// ThreadService contains methods and other services that help with interacting
+// with the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewThreadService] method instead.
+type ThreadService struct {
+ Options []option.RequestOption
+}
+
+// NewThreadService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewThreadService(opts ...option.RequestOption) (r *ThreadService) {
+ r = &ThreadService{}
+ r.Options = opts
+ return
+}
+
+func (r *ThreadService) New(ctx context.Context, agentID string, body ThreadNewParams, opts ...option.RequestOption) (res *Thread, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *ThreadService) Get(ctx context.Context, agentID string, threadID string, query ThreadGetParams, opts ...option.RequestOption) (res *Thread, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
+ return res, err
+}
+
+func (r *ThreadService) List(ctx context.Context, agentID string, query ThreadListParams, opts ...option.RequestOption) (res *pagination.ThreadsCursorPage[ThreadSummary], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads", agentID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ThreadService) ListAutoPaging(ctx context.Context, agentID string, query ThreadListParams, opts ...option.RequestOption) *pagination.ThreadsCursorPageAutoPager[ThreadSummary] {
+ return pagination.NewThreadsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
+}
+
+// Cancel a running or awaiting thread. The underlying runtime treats repeat
+// cancellation as an idempotent lifecycle operation when possible.
+func (r *ThreadService) Cancel(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/cancel", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
+ return res, err
+}
+
+// Close an idle thread. Closing a running, awaiting, or already-closed thread
+// returns a lifecycle conflict.
+func (r *ThreadService) Close(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/close", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
+ return res, err
+}
+
+// Force context compaction for an idle thread. Compacting a running thread returns
+// a lifecycle conflict.
+func (r *ThreadService) Compact(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/compact", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *ThreadService) StartTurn(ctx context.Context, agentID string, threadID string, body ThreadStartTurnParams, opts ...option.RequestOption) (res *Turn, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/turns", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// Steer a thread with another user message. Steering a closed thread returns a
+// conflict; steering a running or awaiting thread queues the message.
+func (r *ThreadService) Steer(ctx context.Context, agentID string, threadID string, body ThreadSteerParams, opts ...option.RequestOption) (res *SteerResult, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/steer", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+type CompiledContext struct {
+ EnabledTools []shared.ToolName `json:"enabledTools" api:"required,nullable"`
+ SystemPrompt string `json:"systemPrompt" api:"required,nullable"`
+ TurnID string `json:"turnId" api:"required,nullable"`
+ JSON compiledContextJSON `json:"-"`
+}
+
+// compiledContextJSON contains the JSON metadata for the struct [CompiledContext]
+type compiledContextJSON struct {
+ EnabledTools apijson.Field
+ SystemPrompt apijson.Field
+ TurnID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *CompiledContext) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r compiledContextJSON) RawJSON() string {
+ return r.raw
+}
+
+type ContentBlock map[string]interface{}
+
+type ContextWindow struct {
+ Compacted bool `json:"compacted" api:"required"`
+ CompactionThroughSeq float64 `json:"compactionThroughSeq" api:"required,nullable"`
+ ContextWindowTokens float64 `json:"contextWindowTokens" api:"required"`
+ EstimationMethod ContextWindowEstimationMethod `json:"estimationMethod" api:"required"`
+ LlmEstimatedTokens float64 `json:"llmEstimatedTokens" api:"required"`
+ Model string `json:"model" api:"required"`
+ RawEstimatedTokens float64 `json:"rawEstimatedTokens" api:"required"`
+ JSON contextWindowJSON `json:"-"`
+}
+
+// contextWindowJSON contains the JSON metadata for the struct [ContextWindow]
+type contextWindowJSON struct {
+ Compacted apijson.Field
+ CompactionThroughSeq apijson.Field
+ ContextWindowTokens apijson.Field
+ EstimationMethod apijson.Field
+ LlmEstimatedTokens apijson.Field
+ Model apijson.Field
+ RawEstimatedTokens apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ContextWindow) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r contextWindowJSON) RawJSON() string {
+ return r.raw
+}
+
+type ContextWindowEstimationMethod string
+
+const (
+ ContextWindowEstimationMethodHeuristicRequestV1 ContextWindowEstimationMethod = "heuristic_request_v1"
+)
+
+func (r ContextWindowEstimationMethod) IsKnown() bool {
+ switch r {
+ case ContextWindowEstimationMethodHeuristicRequestV1:
+ return true
+ }
+ return false
+}
+
+type Message struct {
+ Content []ContentBlock `json:"content" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Role MessageRole `json:"role" api:"required"`
+ Seq float64 `json:"seq" api:"required"`
+ JSON messageJSON `json:"-"`
+}
+
+// messageJSON contains the JSON metadata for the struct [Message]
+type messageJSON struct {
+ Content apijson.Field
+ CreatedAt apijson.Field
+ Role apijson.Field
+ Seq apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Message) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r messageJSON) RawJSON() string {
+ return r.raw
+}
+
+type MessageRole string
+
+const (
+ MessageRoleUser MessageRole = "user"
+ MessageRoleAssistant MessageRole = "assistant"
+)
+
+func (r MessageRole) IsKnown() bool {
+ switch r {
+ case MessageRoleUser, MessageRoleAssistant:
+ return true
+ }
+ return false
+}
+
+type PendingSubThread struct {
+ SubThreadID string `json:"subThreadId" api:"required"`
+ ToolUseID string `json:"toolUseId" api:"required"`
+ JSON pendingSubThreadJSON `json:"-"`
+}
+
+// pendingSubThreadJSON contains the JSON metadata for the struct
+// [PendingSubThread]
+type pendingSubThreadJSON struct {
+ SubThreadID apijson.Field
+ ToolUseID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *PendingSubThread) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r pendingSubThreadJSON) RawJSON() string {
+ return r.raw
+}
+
+// `idle` threads can accept a new turn or be closed. `running` threads have an
+// active turn. `awaiting` threads are paused on external input such as approvals.
+// `closed` threads are terminal.
+type Status string
+
+const (
+ StatusIdle Status = "idle"
+ StatusRunning Status = "running"
+ StatusAwaiting Status = "awaiting"
+ StatusClosed Status = "closed"
+)
+
+func (r Status) IsKnown() bool {
+ switch r {
+ case StatusIdle, StatusRunning, StatusAwaiting, StatusClosed:
+ return true
+ }
+ return false
+}
+
+type SteerResult struct {
+ Status SteerResultStatus `json:"status" api:"required"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ ThreadStatus Status `json:"threadStatus" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ JSON steerResultJSON `json:"-"`
+}
+
+// steerResultJSON contains the JSON metadata for the struct [SteerResult]
+type steerResultJSON struct {
+ Status apijson.Field
+ ThreadStatus apijson.Field
+ TurnID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SteerResult) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r steerResultJSON) RawJSON() string {
+ return r.raw
+}
+
+type SteerResultStatus string
+
+const (
+ SteerResultStatusEnqueued SteerResultStatus = "enqueued"
+ SteerResultStatusTurnStarted SteerResultStatus = "turn_started"
+)
+
+func (r SteerResultStatus) IsKnown() bool {
+ switch r {
+ case SteerResultStatusEnqueued, SteerResultStatusTurnStarted:
+ return true
+ }
+ return false
+}
+
+type Thread struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ CompactionSummary string `json:"compactionSummary" api:"required,nullable"`
+ CompactionThroughSeq float64 `json:"compactionThroughSeq" api:"required,nullable"`
+ CompiledContext CompiledContext `json:"compiledContext" api:"required,nullable"`
+ CompletedAt string `json:"completedAt" api:"required,nullable"`
+ ComposedSystemPrompt string `json:"composedSystemPrompt" api:"required,nullable"`
+ ContextWindow ContextWindow `json:"contextWindow" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Depth float64 `json:"depth" api:"required"`
+ Error string `json:"error" api:"required,nullable"`
+ Instructions string `json:"instructions" api:"required,nullable"`
+ LastTurnStatus ThreadLastTurnStatus `json:"lastTurnStatus" api:"required,nullable"`
+ Messages []Message `json:"messages" api:"required"`
+ Model string `json:"model" api:"required"`
+ ParentThreadID string `json:"parentThreadId" api:"required,nullable"`
+ PendingSubThreads []PendingSubThread `json:"pendingSubThreads" api:"required"`
+ Result string `json:"result" api:"required,nullable"`
+ ScheduleID string `json:"scheduleId" api:"required,nullable"`
+ ScheduleSeq float64 `json:"scheduleSeq" api:"required,nullable"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ Status Status `json:"status" api:"required"`
+ SubThreads []ThreadSummary `json:"subThreads" api:"required"`
+ ToolSnapshot []shared.ToolName `json:"toolSnapshot" api:"required"`
+ Turns []Turn `json:"turns" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ UserMessage string `json:"userMessage" api:"required"`
+ ExternalToolNamespaces ThreadExternalToolNamespacesUnion `json:"externalToolNamespaces"`
+ JSON threadJSON `json:"-"`
+}
+
+// threadJSON contains the JSON metadata for the struct [Thread]
+type threadJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ CompactionSummary apijson.Field
+ CompactionThroughSeq apijson.Field
+ CompiledContext apijson.Field
+ CompletedAt apijson.Field
+ ComposedSystemPrompt apijson.Field
+ ContextWindow apijson.Field
+ CreatedAt apijson.Field
+ Depth apijson.Field
+ Error apijson.Field
+ Instructions apijson.Field
+ LastTurnStatus apijson.Field
+ Messages apijson.Field
+ Model apijson.Field
+ ParentThreadID apijson.Field
+ PendingSubThreads apijson.Field
+ Result apijson.Field
+ ScheduleID apijson.Field
+ ScheduleSeq apijson.Field
+ Status apijson.Field
+ SubThreads apijson.Field
+ ToolSnapshot apijson.Field
+ Turns apijson.Field
+ UpdatedAt apijson.Field
+ UserMessage apijson.Field
+ ExternalToolNamespaces apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Thread) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadJSON) RawJSON() string {
+ return r.raw
+}
+
+type ThreadLastTurnStatus string
+
+const (
+ ThreadLastTurnStatusCompleted ThreadLastTurnStatus = "completed"
+ ThreadLastTurnStatusFailed ThreadLastTurnStatus = "failed"
+)
+
+func (r ThreadLastTurnStatus) IsKnown() bool {
+ switch r {
+ case ThreadLastTurnStatusCompleted, ThreadLastTurnStatusFailed:
+ return true
+ }
+ return false
+}
+
+// Union satisfied by [ThreadExternalToolNamespacesString] or
+// [ThreadExternalToolNamespacesArray].
+type ThreadExternalToolNamespacesUnion interface {
+ implementsThreadExternalToolNamespacesUnion()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ThreadExternalToolNamespacesUnion)(nil)).Elem(),
+ "",
+ apijson.UnionVariant{
+ TypeFilter: gjson.String,
+ Type: reflect.TypeOf(ThreadExternalToolNamespacesString("")),
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadExternalToolNamespacesArray{}),
+ },
+ )
+}
+
+type ThreadExternalToolNamespacesString string
+
+const (
+ ThreadExternalToolNamespacesStringAll ThreadExternalToolNamespacesString = "all"
+)
+
+func (r ThreadExternalToolNamespacesString) IsKnown() bool {
+ switch r {
+ case ThreadExternalToolNamespacesStringAll:
+ return true
+ }
+ return false
+}
+
+func (r ThreadExternalToolNamespacesString) implementsThreadExternalToolNamespacesUnion() {}
+
+type ThreadExternalToolNamespacesArray []string
+
+func (r ThreadExternalToolNamespacesArray) implementsThreadExternalToolNamespacesUnion() {}
+
+type ThreadSummary struct {
+ ID string `json:"id" api:"required"`
+ CompletedAt string `json:"completedAt" api:"required,nullable"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ MessageCount float64 `json:"messageCount" api:"required"`
+ Model string `json:"model" api:"required"`
+ ParentThreadID string `json:"parentThreadId" api:"required,nullable"`
+ Result string `json:"result" api:"required,nullable"`
+ ScheduleID string `json:"scheduleId" api:"required,nullable"`
+ ScheduleSeq float64 `json:"scheduleSeq" api:"required,nullable"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ Status Status `json:"status" api:"required"`
+ StepCount float64 `json:"stepCount" api:"required"`
+ JSON threadSummaryJSON `json:"-"`
+}
+
+// threadSummaryJSON contains the JSON metadata for the struct [ThreadSummary]
+type threadSummaryJSON struct {
+ ID apijson.Field
+ CompletedAt apijson.Field
+ CreatedAt apijson.Field
+ MessageCount apijson.Field
+ Model apijson.Field
+ ParentThreadID apijson.Field
+ Result apijson.Field
+ ScheduleID apijson.Field
+ ScheduleSeq apijson.Field
+ Status apijson.Field
+ StepCount apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadSummary) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadSummaryJSON) RawJSON() string {
+ return r.raw
+}
+
+type TokenUsage struct {
+ InputTokens float64 `json:"inputTokens" api:"required"`
+ OutputTokens float64 `json:"outputTokens" api:"required"`
+ JSON tokenUsageJSON `json:"-"`
+}
+
+// tokenUsageJSON contains the JSON metadata for the struct [TokenUsage]
+type tokenUsageJSON struct {
+ InputTokens apijson.Field
+ OutputTokens apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *TokenUsage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r tokenUsageJSON) RawJSON() string {
+ return r.raw
+}
+
+type Turn struct {
+ ID string `json:"id" api:"required"`
+ CompletedAt string `json:"completedAt" api:"required,nullable"`
+ EndMessageSeq float64 `json:"endMessageSeq" api:"required,nullable"`
+ Error string `json:"error" api:"required,nullable"`
+ Result string `json:"result" api:"required,nullable"`
+ Seq float64 `json:"seq" api:"required"`
+ StartedAt string `json:"startedAt" api:"required"`
+ StartMessageSeq float64 `json:"startMessageSeq" api:"required"`
+ Status TurnStatus `json:"status" api:"required"`
+ ThreadID string `json:"threadId" api:"required"`
+ TokenUsage TokenUsage `json:"tokenUsage" api:"required,nullable"`
+ UserMessage string `json:"userMessage" api:"required"`
+ JSON turnJSON `json:"-"`
+}
+
+// turnJSON contains the JSON metadata for the struct [Turn]
+type turnJSON struct {
+ ID apijson.Field
+ CompletedAt apijson.Field
+ EndMessageSeq apijson.Field
+ Error apijson.Field
+ Result apijson.Field
+ Seq apijson.Field
+ StartedAt apijson.Field
+ StartMessageSeq apijson.Field
+ Status apijson.Field
+ ThreadID apijson.Field
+ TokenUsage apijson.Field
+ UserMessage apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Turn) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r turnJSON) RawJSON() string {
+ return r.raw
+}
+
+type TurnStatus string
+
+const (
+ TurnStatusRunning TurnStatus = "running"
+ TurnStatusCompleted TurnStatus = "completed"
+ TurnStatusFailed TurnStatus = "failed"
+)
+
+func (r TurnStatus) IsKnown() bool {
+ switch r {
+ case TurnStatusRunning, TurnStatusCompleted, TurnStatusFailed:
+ return true
+ }
+ return false
+}
+
+type ThreadNewParams struct {
+ Instructions param.Field[string] `json:"instructions"`
+ Model param.Field[string] `json:"model"`
+ // Deprecated alias for `instructions`; accepted for backwards compatibility.
+ SystemPrompt param.Field[string] `json:"systemPrompt"`
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+ UserMessage param.Field[string] `json:"userMessage"`
+}
+
+func (r ThreadNewParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type ThreadGetParams struct {
+ // When true, includes debug-only compiled context fields.
+ Debug param.Field[ThreadGetParamsDebug] `query:"debug"`
+ // When true, includes message content in the thread detail.
+ IncludeMessages param.Field[ThreadGetParamsIncludeMessages] `query:"includeMessages"`
+}
+
+// URLQuery serializes [ThreadGetParams]'s query parameters as `url.Values`.
+func (r ThreadGetParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, includes debug-only compiled context fields.
+type ThreadGetParamsDebug string
+
+const (
+ ThreadGetParamsDebugTrue ThreadGetParamsDebug = "true"
+ ThreadGetParamsDebugFalse ThreadGetParamsDebug = "false"
+)
+
+func (r ThreadGetParamsDebug) IsKnown() bool {
+ switch r {
+ case ThreadGetParamsDebugTrue, ThreadGetParamsDebugFalse:
+ return true
+ }
+ return false
+}
+
+// When true, includes message content in the thread detail.
+type ThreadGetParamsIncludeMessages string
+
+const (
+ ThreadGetParamsIncludeMessagesTrue ThreadGetParamsIncludeMessages = "true"
+ ThreadGetParamsIncludeMessagesFalse ThreadGetParamsIncludeMessages = "false"
+)
+
+func (r ThreadGetParamsIncludeMessages) IsKnown() bool {
+ switch r {
+ case ThreadGetParamsIncludeMessagesTrue, ThreadGetParamsIncludeMessagesFalse:
+ return true
+ }
+ return false
+}
+
+type ThreadListParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+ // Optional schedule id filter.
+ ScheduleID param.Field[string] `query:"scheduleId"`
+ // Optional thread status filter.
+ Status param.Field[Status] `query:"status"`
+}
+
+// URLQuery serializes [ThreadListParams]'s query parameters as `url.Values`.
+func (r ThreadListParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+type ThreadStartTurnParams struct {
+ UserMessage param.Field[string] `json:"userMessage" api:"required"`
+ Model param.Field[string] `json:"model"`
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+}
+
+func (r ThreadStartTurnParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type ThreadSteerParams struct {
+ Message param.Field[string] `json:"message" api:"required"`
+}
+
+func (r ThreadSteerParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/cellthread_test.go b/thread_test.go
similarity index 76%
rename from cellthread_test.go
rename to thread_test.go
index 1a2cc6e..184488c 100644
--- a/cellthread_test.go
+++ b/thread_test.go
@@ -11,9 +11,10 @@ import (
"github.com/matrices/cerca-go"
"github.com/matrices/cerca-go/internal/testutil"
"github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/shared"
)
-func TestCellThreadNewWithOptionalParams(t *testing.T) {
+func TestThreadNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,14 +26,14 @@ func TestCellThreadNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.New(
+ _, err := client.Threads.New(
context.TODO(),
- "cell_abc123",
- cercago.CellThreadNewParams{
- Features: cercago.F([]cercago.CellThreadNewParamsFeature{cercago.CellThreadNewParamsFeatureMemory}),
+ "agent_abc123",
+ cercago.ThreadNewParams{
Instructions: cercago.F("instructions"),
Model: cercago.F("model"),
SystemPrompt: cercago.F("systemPrompt"),
+ Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
UserMessage: cercago.F("userMessage"),
},
)
@@ -45,7 +46,7 @@ func TestCellThreadNewWithOptionalParams(t *testing.T) {
}
}
-func TestCellThreadGetWithOptionalParams(t *testing.T) {
+func TestThreadGetWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -57,13 +58,13 @@ func TestCellThreadGetWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Get(
+ _, err := client.Threads.Get(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"thread_abc123",
- cercago.CellThreadGetParams{
- Debug: cercago.F(cercago.CellThreadGetParamsDebugFalse),
- IncludeMessages: cercago.F(cercago.CellThreadGetParamsIncludeMessagesTrue),
+ cercago.ThreadGetParams{
+ Debug: cercago.F(cercago.ThreadGetParamsDebugFalse),
+ IncludeMessages: cercago.F(cercago.ThreadGetParamsIncludeMessagesTrue),
},
)
if err != nil {
@@ -75,7 +76,7 @@ func TestCellThreadGetWithOptionalParams(t *testing.T) {
}
}
-func TestCellThreadListWithOptionalParams(t *testing.T) {
+func TestThreadListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -87,14 +88,14 @@ func TestCellThreadListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.List(
+ _, err := client.Threads.List(
context.TODO(),
- "cell_abc123",
- cercago.CellThreadListParams{
+ "agent_abc123",
+ cercago.ThreadListParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
ScheduleID: cercago.F("schedule_abc123"),
- Status: cercago.F(cercago.ThreadStatusIdle),
+ Status: cercago.F(cercago.StatusIdle),
},
)
if err != nil {
@@ -106,7 +107,7 @@ func TestCellThreadListWithOptionalParams(t *testing.T) {
}
}
-func TestCellThreadCancel(t *testing.T) {
+func TestThreadCancel(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -118,9 +119,9 @@ func TestCellThreadCancel(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Cancel(
+ _, err := client.Threads.Cancel(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"thread_abc123",
)
if err != nil {
@@ -132,7 +133,7 @@ func TestCellThreadCancel(t *testing.T) {
}
}
-func TestCellThreadClose(t *testing.T) {
+func TestThreadClose(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -144,9 +145,9 @@ func TestCellThreadClose(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Close(
+ _, err := client.Threads.Close(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"thread_abc123",
)
if err != nil {
@@ -158,7 +159,7 @@ func TestCellThreadClose(t *testing.T) {
}
}
-func TestCellThreadCompact(t *testing.T) {
+func TestThreadCompact(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -170,9 +171,9 @@ func TestCellThreadCompact(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Compact(
+ _, err := client.Threads.Compact(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"thread_abc123",
)
if err != nil {
@@ -184,7 +185,7 @@ func TestCellThreadCompact(t *testing.T) {
}
}
-func TestCellThreadSteer(t *testing.T) {
+func TestThreadStartTurnWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -196,12 +197,14 @@ func TestCellThreadSteer(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Steer(
+ _, err := client.Threads.StartTurn(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"thread_abc123",
- cercago.CellThreadSteerParams{
- Message: cercago.F("message"),
+ cercago.ThreadStartTurnParams{
+ UserMessage: cercago.F("userMessage"),
+ Model: cercago.F("model"),
+ Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
},
)
if err != nil {
@@ -213,7 +216,7 @@ func TestCellThreadSteer(t *testing.T) {
}
}
-func TestCellThreadTurnWithOptionalParams(t *testing.T) {
+func TestThreadSteer(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -225,14 +228,12 @@ func TestCellThreadTurnWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Turn(
+ _, err := client.Threads.Steer(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"thread_abc123",
- cercago.CellThreadTurnParams{
- UserMessage: cercago.F("userMessage"),
- Features: cercago.F([]cercago.CellThreadTurnParamsFeature{cercago.CellThreadTurnParamsFeatureMemory}),
- Model: cercago.F("model"),
+ cercago.ThreadSteerParams{
+ Message: cercago.F("message"),
},
)
if err != nil {
diff --git a/celltool.go b/tool.go
similarity index 56%
rename from celltool.go
rename to tool.go
index 9764520..e5b019c 100644
--- a/celltool.go
+++ b/tool.go
@@ -12,34 +12,35 @@ import (
"github.com/matrices/cerca-go/internal/apijson"
"github.com/matrices/cerca-go/internal/requestconfig"
"github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/shared"
)
-// CellToolService contains methods and other services that help with interacting
-// with the cerca API.
+// ToolService contains methods and other services that help with interacting with
+// the cerca API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
-// the [NewCellToolService] method instead.
-type CellToolService struct {
+// the [NewToolService] method instead.
+type ToolService struct {
Options []option.RequestOption
}
-// NewCellToolService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCellToolService(opts ...option.RequestOption) (r *CellToolService) {
- r = &CellToolService{}
+// NewToolService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewToolService(opts ...option.RequestOption) (r *ToolService) {
+ r = &ToolService{}
r.Options = opts
return
}
-func (r *CellToolService) List(ctx context.Context, cellID string, opts ...option.RequestOption) (res *CellToolListResponse, err error) {
+func (r *ToolService) ListForAgent(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ToolListForAgentResponse, err error) {
opts = slices.Concat(r.Options, opts)
- if cellID == "" {
- err = errors.New("missing required cellId parameter")
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
return nil, err
}
- path := fmt.Sprintf("cells/%s/tools", cellID)
+ path := fmt.Sprintf("agents/%s/tools", agentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -48,7 +49,7 @@ type RuntimeDiscoveredTool struct {
Approval RuntimeDiscoveredToolApproval `json:"approval" api:"required"`
Description string `json:"description" api:"required"`
// JSON Schema object describing tool input parameters.
- InputSchema interface{} `json:"inputSchema" api:"required"`
+ InputSchema map[string]interface{} `json:"inputSchema" api:"required"`
Name string `json:"name" api:"required"`
Origin RuntimeDiscoveredToolOrigin `json:"origin" api:"required"`
Source string `json:"source" api:"required"`
@@ -143,8 +144,8 @@ func (r runtimeSourceWarningJSON) RawJSON() string {
type RuntimeToolDescriptor struct {
Description string `json:"description" api:"required"`
- InputSchema interface{} `json:"inputSchema" api:"required"`
- Name RuntimeToolName `json:"name" api:"required"`
+ InputSchema shared.JsonObject `json:"inputSchema" api:"required"`
+ Name shared.ToolName `json:"name" api:"required"`
JSON runtimeToolDescriptorJSON `json:"-"`
}
@@ -166,51 +167,16 @@ func (r runtimeToolDescriptorJSON) RawJSON() string {
return r.raw
}
-type RuntimeToolName string
-
-const (
- RuntimeToolNameWebSearch RuntimeToolName = "web_search"
- RuntimeToolNameWebFetch RuntimeToolName = "web_fetch"
- RuntimeToolNameSandboxExec RuntimeToolName = "sandbox_exec"
- RuntimeToolNameSandboxRead RuntimeToolName = "sandbox_read"
- RuntimeToolNameSandboxWriteFile RuntimeToolName = "sandbox_write_file"
- RuntimeToolNameSandboxReadFile RuntimeToolName = "sandbox_read_file"
- RuntimeToolNameCellDB RuntimeToolName = "cell_db"
- RuntimeToolNameContextRead RuntimeToolName = "context_read"
- RuntimeToolNameContextList RuntimeToolName = "context_list"
- RuntimeToolNameContextSearch RuntimeToolName = "context_search"
- RuntimeToolNameBlobSync RuntimeToolName = "blob_sync"
- RuntimeToolNameContextSync RuntimeToolName = "context_sync"
- RuntimeToolNameContextWrite RuntimeToolName = "context_write"
- RuntimeToolNameContextDelete RuntimeToolName = "context_delete"
- RuntimeToolNameToolDiscover RuntimeToolName = "tool_discover"
- RuntimeToolNameToolCall RuntimeToolName = "tool_call"
- RuntimeToolNameArtifactRead RuntimeToolName = "artifact_read"
- RuntimeToolNameArtifactSync RuntimeToolName = "artifact_sync"
- RuntimeToolNameToolConnect RuntimeToolName = "tool_connect"
- RuntimeToolNameSubThread RuntimeToolName = "sub_thread"
- RuntimeToolNameWait RuntimeToolName = "wait"
- RuntimeToolNameGetCurrentTime RuntimeToolName = "get_current_time"
-)
-
-func (r RuntimeToolName) IsKnown() bool {
- switch r {
- case RuntimeToolNameWebSearch, RuntimeToolNameWebFetch, RuntimeToolNameSandboxExec, RuntimeToolNameSandboxRead, RuntimeToolNameSandboxWriteFile, RuntimeToolNameSandboxReadFile, RuntimeToolNameCellDB, RuntimeToolNameContextRead, RuntimeToolNameContextList, RuntimeToolNameContextSearch, RuntimeToolNameBlobSync, RuntimeToolNameContextSync, RuntimeToolNameContextWrite, RuntimeToolNameContextDelete, RuntimeToolNameToolDiscover, RuntimeToolNameToolCall, RuntimeToolNameArtifactRead, RuntimeToolNameArtifactSync, RuntimeToolNameToolConnect, RuntimeToolNameSubThread, RuntimeToolNameWait, RuntimeToolNameGetCurrentTime:
- return true
- }
- return false
-}
-
-type CellToolListResponse struct {
- DiscoveredTools []RuntimeDiscoveredTool `json:"discoveredTools" api:"required"`
- Tools []RuntimeToolDescriptor `json:"tools" api:"required"`
- SourceWarnings []RuntimeSourceWarning `json:"sourceWarnings"`
- JSON cellToolListResponseJSON `json:"-"`
+type ToolListForAgentResponse struct {
+ DiscoveredTools []RuntimeDiscoveredTool `json:"discoveredTools" api:"required"`
+ Tools []RuntimeToolDescriptor `json:"tools" api:"required"`
+ SourceWarnings []RuntimeSourceWarning `json:"sourceWarnings"`
+ JSON toolListForAgentResponseJSON `json:"-"`
}
-// cellToolListResponseJSON contains the JSON metadata for the struct
-// [CellToolListResponse]
-type cellToolListResponseJSON struct {
+// toolListForAgentResponseJSON contains the JSON metadata for the struct
+// [ToolListForAgentResponse]
+type toolListForAgentResponseJSON struct {
DiscoveredTools apijson.Field
Tools apijson.Field
SourceWarnings apijson.Field
@@ -218,10 +184,10 @@ type cellToolListResponseJSON struct {
ExtraFields map[string]apijson.Field
}
-func (r *CellToolListResponse) UnmarshalJSON(data []byte) (err error) {
+func (r *ToolListForAgentResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r cellToolListResponseJSON) RawJSON() string {
+func (r toolListForAgentResponseJSON) RawJSON() string {
return r.raw
}
diff --git a/cellconfig_test.go b/tool_test.go
similarity index 86%
rename from cellconfig_test.go
rename to tool_test.go
index 2ac7047..5683e36 100644
--- a/cellconfig_test.go
+++ b/tool_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellConfigGet(t *testing.T) {
+func TestToolListForAgent(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,7 +25,7 @@ func TestCellConfigGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Config.Get(context.TODO(), "cell_abc123")
+ _, err := client.Tools.ListForAgent(context.TODO(), "agent_abc123")
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
diff --git a/toolsource.go b/toolsource.go
new file mode 100644
index 0000000..ddaeaff
--- /dev/null
+++ b/toolsource.go
@@ -0,0 +1,665 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "reflect"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+ "github.com/tidwall/gjson"
+)
+
+// ToolSourceService contains methods and other services that help with interacting
+// with the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewToolSourceService] method instead.
+type ToolSourceService struct {
+ Options []option.RequestOption
+}
+
+// NewToolSourceService generates a new service that applies the given options to
+// each request. These options are applied after the parent client's options (if
+// there is one), and before any request-specific options.
+func NewToolSourceService(opts ...option.RequestOption) (r *ToolSourceService) {
+ r = &ToolSourceService{}
+ r.Options = opts
+ return
+}
+
+func (r *ToolSourceService) New(ctx context.Context, fleetID string, body ToolSourceNewParams, opts ...option.RequestOption) (res *ToolSource, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources", fleetID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *ToolSourceService) Get(ctx context.Context, fleetID string, sourceID string, opts ...option.RequestOption) (res *ToolSource, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ if sourceID == "" {
+ err = errors.New("missing required sourceId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *ToolSourceService) Update(ctx context.Context, fleetID string, sourceID string, body ToolSourceUpdateParams, opts ...option.RequestOption) (res *ToolSource, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ if sourceID == "" {
+ err = errors.New("missing required sourceId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *ToolSourceService) List(ctx context.Context, fleetID string, query ToolSourceListParams, opts ...option.RequestOption) (res *pagination.SourcesCursorPage[ToolSource], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources", fleetID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *ToolSourceService) ListAutoPaging(ctx context.Context, fleetID string, query ToolSourceListParams, opts ...option.RequestOption) *pagination.SourcesCursorPageAutoPager[ToolSource] {
+ return pagination.NewSourcesCursorPageAutoPager(r.List(ctx, fleetID, query, opts...))
+}
+
+func (r *ToolSourceService) Delete(ctx context.Context, fleetID string, sourceID string, opts ...option.RequestOption) (err error) {
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return err
+ }
+ if sourceID == "" {
+ err = errors.New("missing required sourceId parameter")
+ return err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
+ return err
+}
+
+func (r *ToolSourceService) ListForAgent(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ToolSourceListForAgentResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/tool-sources", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+type HTTPToolDefinition map[string]interface{}
+
+type HTTPToolDefinitionParam map[string]interface{}
+
+type HTTPToolExecutionPolicy map[string]interface{}
+
+type HTTPToolExecutionPolicyParam map[string]interface{}
+
+type HTTPToolSource struct {
+ ID string `json:"id" api:"required"`
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth ToolSourceAuth `json:"auth" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ Namespace string `json:"namespace" api:"required"`
+ Tools []HTTPToolDefinition `json:"tools" api:"required"`
+ Type HTTPToolSourceType `json:"type" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ Approval ToolApprovalMode `json:"approval"`
+ // HTTP tool execution retry and timeout policy.
+ Execution HTTPToolExecutionPolicy `json:"execution"`
+ JSON httpToolSourceJSON `json:"-"`
+}
+
+// httpToolSourceJSON contains the JSON metadata for the struct [HTTPToolSource]
+type httpToolSourceJSON struct {
+ ID apijson.Field
+ Auth apijson.Field
+ CreatedAt apijson.Field
+ Enabled apijson.Field
+ FleetID apijson.Field
+ Namespace apijson.Field
+ Tools apijson.Field
+ Type apijson.Field
+ UpdatedAt apijson.Field
+ Version apijson.Field
+ Approval apijson.Field
+ Execution apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *HTTPToolSource) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r httpToolSourceJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r HTTPToolSource) implementsToolSource() {}
+
+type HTTPToolSourceType string
+
+const (
+ HTTPToolSourceTypeHTTP HTTPToolSourceType = "http"
+)
+
+func (r HTTPToolSourceType) IsKnown() bool {
+ switch r {
+ case HTTPToolSourceTypeHTTP:
+ return true
+ }
+ return false
+}
+
+type McpToolExecutionPolicy map[string]interface{}
+
+type McpToolExecutionPolicyParam map[string]interface{}
+
+type McpToolSource struct {
+ ID string `json:"id" api:"required"`
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth ToolSourceAuth `json:"auth" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ Namespace string `json:"namespace" api:"required"`
+ Type McpToolSourceType `json:"type" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ URL string `json:"url" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ Approval ToolApprovalMode `json:"approval"`
+ // MCP discovery and execution retry/timeout policy.
+ Execution McpToolExecutionPolicy `json:"execution"`
+ JSON mcpToolSourceJSON `json:"-"`
+}
+
+// mcpToolSourceJSON contains the JSON metadata for the struct [McpToolSource]
+type mcpToolSourceJSON struct {
+ ID apijson.Field
+ Auth apijson.Field
+ CreatedAt apijson.Field
+ Enabled apijson.Field
+ FleetID apijson.Field
+ Namespace apijson.Field
+ Type apijson.Field
+ UpdatedAt apijson.Field
+ URL apijson.Field
+ Version apijson.Field
+ Approval apijson.Field
+ Execution apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *McpToolSource) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r mcpToolSourceJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r McpToolSource) implementsToolSource() {}
+
+type McpToolSourceType string
+
+const (
+ McpToolSourceTypeMcp McpToolSourceType = "mcp"
+)
+
+func (r McpToolSourceType) IsKnown() bool {
+ switch r {
+ case McpToolSourceTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolApprovalMode string
+
+const (
+ ToolApprovalModeAlways ToolApprovalMode = "always"
+ ToolApprovalModeNever ToolApprovalMode = "never"
+)
+
+func (r ToolApprovalMode) IsKnown() bool {
+ switch r {
+ case ToolApprovalModeAlways, ToolApprovalModeNever:
+ return true
+ }
+ return false
+}
+
+type ToolSource struct {
+ ID string `json:"id" api:"required"`
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth ToolSourceAuth `json:"auth" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ Namespace string `json:"namespace" api:"required"`
+ Type ToolSourceType `json:"type" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ Approval ToolApprovalMode `json:"approval"`
+ // This field can have the runtime type of [HTTPToolExecutionPolicy],
+ // [McpToolExecutionPolicy].
+ Execution interface{} `json:"execution"`
+ // This field can have the runtime type of [[]HTTPToolDefinition].
+ Tools interface{} `json:"tools"`
+ URL string `json:"url"`
+ JSON toolSourceJSON `json:"-"`
+ union ToolSourceUnion
+}
+
+// toolSourceJSON contains the JSON metadata for the struct [ToolSource]
+type toolSourceJSON struct {
+ ID apijson.Field
+ Auth apijson.Field
+ CreatedAt apijson.Field
+ Enabled apijson.Field
+ FleetID apijson.Field
+ Namespace apijson.Field
+ Type apijson.Field
+ UpdatedAt apijson.Field
+ Version apijson.Field
+ Approval apijson.Field
+ Execution apijson.Field
+ Tools apijson.Field
+ URL apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r toolSourceJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *ToolSource) UnmarshalJSON(data []byte) (err error) {
+ *r = ToolSource{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [ToolSourceUnion] interface which you can cast to the specific
+// types for more type safety.
+//
+// Possible runtime types of the union are [HTTPToolSource], [McpToolSource].
+func (r ToolSource) AsUnion() ToolSourceUnion {
+ return r.union
+}
+
+// Union satisfied by [HTTPToolSource] or [McpToolSource].
+type ToolSourceUnion interface {
+ implementsToolSource()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ToolSourceUnion)(nil)).Elem(),
+ "type",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(HTTPToolSource{}),
+ DiscriminatorValue: "http",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(McpToolSource{}),
+ DiscriminatorValue: "mcp",
+ },
+ )
+}
+
+type ToolSourceType string
+
+const (
+ ToolSourceTypeHTTP ToolSourceType = "http"
+ ToolSourceTypeMcp ToolSourceType = "mcp"
+)
+
+func (r ToolSourceType) IsKnown() bool {
+ switch r {
+ case ToolSourceTypeHTTP, ToolSourceTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolSourceAuth map[string]interface{}
+
+type ToolSourceAuthParam map[string]interface{}
+
+type ToolSourceListForAgentResponse struct {
+ Cursor string `json:"cursor" api:"required,nullable"`
+ HasMore bool `json:"hasMore" api:"required"`
+ Sources []ToolSource `json:"sources" api:"required"`
+ JSON toolSourceListForAgentResponseJSON `json:"-"`
+}
+
+// toolSourceListForAgentResponseJSON contains the JSON metadata for the struct
+// [ToolSourceListForAgentResponse]
+type toolSourceListForAgentResponseJSON struct {
+ Cursor apijson.Field
+ HasMore apijson.Field
+ Sources apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ToolSourceListForAgentResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r toolSourceListForAgentResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ToolSourceNewParams struct {
+ Source ToolSourceNewParamsSourceUnion `json:"source" api:"required"`
+}
+
+func (r ToolSourceNewParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r.Source)
+}
+
+type ToolSourceNewParamsSource struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Type param.Field[ToolSourceNewParamsSourceType] `json:"type" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ Execution param.Field[interface{}] `json:"execution"`
+ Tools param.Field[interface{}] `json:"tools"`
+ URL param.Field[string] `json:"url"`
+}
+
+func (r ToolSourceNewParamsSource) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceNewParamsSource) implementsToolSourceNewParamsSourceUnion() {}
+
+// Satisfied by [ToolSourceNewParamsSourceCreateHTTPToolSourceRequest],
+// [ToolSourceNewParamsSourceCreateMcpToolSourceRequest],
+// [ToolSourceNewParamsSource].
+type ToolSourceNewParamsSourceUnion interface {
+ implementsToolSourceNewParamsSourceUnion()
+}
+
+type ToolSourceNewParamsSourceCreateHTTPToolSourceRequest struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
+ Type param.Field[ToolSourceNewParamsSourceCreateHTTPToolSourceRequestType] `json:"type" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ // HTTP tool execution retry and timeout policy.
+ Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolSourceNewParamsSourceCreateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceNewParamsSourceCreateHTTPToolSourceRequest) implementsToolSourceNewParamsSourceUnion() {
+}
+
+type ToolSourceNewParamsSourceCreateHTTPToolSourceRequestType string
+
+const (
+ ToolSourceNewParamsSourceCreateHTTPToolSourceRequestTypeHTTP ToolSourceNewParamsSourceCreateHTTPToolSourceRequestType = "http"
+)
+
+func (r ToolSourceNewParamsSourceCreateHTTPToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolSourceNewParamsSourceCreateHTTPToolSourceRequestTypeHTTP:
+ return true
+ }
+ return false
+}
+
+type ToolSourceNewParamsSourceCreateMcpToolSourceRequest struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Type param.Field[ToolSourceNewParamsSourceCreateMcpToolSourceRequestType] `json:"type" api:"required"`
+ URL param.Field[string] `json:"url" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ // MCP discovery and execution retry/timeout policy.
+ Execution param.Field[McpToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolSourceNewParamsSourceCreateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceNewParamsSourceCreateMcpToolSourceRequest) implementsToolSourceNewParamsSourceUnion() {
+}
+
+type ToolSourceNewParamsSourceCreateMcpToolSourceRequestType string
+
+const (
+ ToolSourceNewParamsSourceCreateMcpToolSourceRequestTypeMcp ToolSourceNewParamsSourceCreateMcpToolSourceRequestType = "mcp"
+)
+
+func (r ToolSourceNewParamsSourceCreateMcpToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolSourceNewParamsSourceCreateMcpToolSourceRequestTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolSourceNewParamsSourceType string
+
+const (
+ ToolSourceNewParamsSourceTypeHTTP ToolSourceNewParamsSourceType = "http"
+ ToolSourceNewParamsSourceTypeMcp ToolSourceNewParamsSourceType = "mcp"
+)
+
+func (r ToolSourceNewParamsSourceType) IsKnown() bool {
+ switch r {
+ case ToolSourceNewParamsSourceTypeHTTP, ToolSourceNewParamsSourceTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolSourceUpdateParams struct {
+ Source ToolSourceUpdateParamsSourceUnion `json:"source" api:"required"`
+}
+
+func (r ToolSourceUpdateParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r.Source)
+}
+
+type ToolSourceUpdateParamsSource struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Type param.Field[ToolSourceUpdateParamsSourceType] `json:"type" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ Execution param.Field[interface{}] `json:"execution"`
+ Tools param.Field[interface{}] `json:"tools"`
+ URL param.Field[string] `json:"url"`
+}
+
+func (r ToolSourceUpdateParamsSource) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceUpdateParamsSource) implementsToolSourceUpdateParamsSourceUnion() {}
+
+// Satisfied by [ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest],
+// [ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequest],
+// [ToolSourceUpdateParamsSource].
+type ToolSourceUpdateParamsSourceUnion interface {
+ implementsToolSourceUpdateParamsSourceUnion()
+}
+
+type ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
+ Type param.Field[ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestType] `json:"type" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ // HTTP tool execution retry and timeout policy.
+ Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest) implementsToolSourceUpdateParamsSourceUnion() {
+}
+
+type ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestType string
+
+const (
+ ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestTypeHTTP ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestType = "http"
+)
+
+func (r ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestTypeHTTP:
+ return true
+ }
+ return false
+}
+
+type ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequest struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Type param.Field[ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestType] `json:"type" api:"required"`
+ URL param.Field[string] `json:"url" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ // MCP discovery and execution retry/timeout policy.
+ Execution param.Field[McpToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequest) implementsToolSourceUpdateParamsSourceUnion() {
+}
+
+type ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestType string
+
+const (
+ ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestTypeMcp ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestType = "mcp"
+)
+
+func (r ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolSourceUpdateParamsSourceType string
+
+const (
+ ToolSourceUpdateParamsSourceTypeHTTP ToolSourceUpdateParamsSourceType = "http"
+ ToolSourceUpdateParamsSourceTypeMcp ToolSourceUpdateParamsSourceType = "mcp"
+)
+
+func (r ToolSourceUpdateParamsSourceType) IsKnown() bool {
+ switch r {
+ case ToolSourceUpdateParamsSourceTypeHTTP, ToolSourceUpdateParamsSourceTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolSourceListParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [ToolSourceListParams]'s query parameters as `url.Values`.
+func (r ToolSourceListParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
diff --git a/environmenttoolsource_test.go b/toolsource_test.go
similarity index 57%
rename from environmenttoolsource_test.go
rename to toolsource_test.go
index 1dc6ecf..e8190e6 100644
--- a/environmenttoolsource_test.go
+++ b/toolsource_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestEnvironmentToolSourceNewWithOptionalParams(t *testing.T) {
+func TestToolSourceNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,33 +25,28 @@ func TestEnvironmentToolSourceNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.ToolSources.New(
+ _, err := client.ToolSources.New(
context.TODO(),
- "env_abc123",
- cercago.EnvironmentToolSourceNewParams{
- Body: cercago.EnvironmentToolSourceNewParamsBodyObject{
- Auth: cercago.F[any](map[string]interface{}{
- "kind": "none",
+ "fleet_abc123",
+ cercago.ToolSourceNewParams{
+ Source: cercago.ToolSourceNewParamsSourceCreateHTTPToolSourceRequest{
+ Auth: cercago.F(cercago.ToolSourceAuthParam{
+ "kind": "bar",
}),
Namespace: cercago.F("docs"),
- Tools: cercago.F([]cercago.HTTPToolDefinitionParam{map[string]interface{}{
- "name": "search",
- "description": "Search documents",
- "inputSchema": map[string]interface{}{
- "type": "object",
- },
- "endpoint": map[string]interface{}{
- "method": "GET",
- "url": "https://docs.example.com/search",
- },
+ Tools: cercago.F([]cercago.HTTPToolDefinitionParam{{
+ "name": "bar",
+ "description": "bar",
+ "inputSchema": "bar",
+ "endpoint": "bar",
}}),
- Type: cercago.F(cercago.EnvironmentToolSourceNewParamsBodyObjectTypeHTTP),
+ Type: cercago.F(cercago.ToolSourceNewParamsSourceCreateHTTPToolSourceRequestTypeHTTP),
Approval: cercago.F(cercago.ToolApprovalModeAlways),
Enabled: cercago.F(true),
- Execution: cercago.F[any](map[string]interface{}{
- "timeoutMs": 10000,
- "maxAttempts": 3,
- "retryMode": "safe_only",
+ Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
+ "timeoutMs": "bar",
+ "maxAttempts": "bar",
+ "retryMode": "bar",
}),
},
},
@@ -65,7 +60,7 @@ func TestEnvironmentToolSourceNewWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentToolSourceGet(t *testing.T) {
+func TestToolSourceGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -77,9 +72,9 @@ func TestEnvironmentToolSourceGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.ToolSources.Get(
+ _, err := client.ToolSources.Get(
context.TODO(),
- "env_abc123",
+ "fleet_abc123",
"toolsrc_abc123",
)
if err != nil {
@@ -91,7 +86,7 @@ func TestEnvironmentToolSourceGet(t *testing.T) {
}
}
-func TestEnvironmentToolSourceUpdateWithOptionalParams(t *testing.T) {
+func TestToolSourceUpdateWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -103,34 +98,29 @@ func TestEnvironmentToolSourceUpdateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.ToolSources.Update(
+ _, err := client.ToolSources.Update(
context.TODO(),
- "env_abc123",
+ "fleet_abc123",
"toolsrc_abc123",
- cercago.EnvironmentToolSourceUpdateParams{
- Body: cercago.EnvironmentToolSourceUpdateParamsBodyObject{
- Auth: cercago.F[any](map[string]interface{}{
- "kind": "none",
+ cercago.ToolSourceUpdateParams{
+ Source: cercago.ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest{
+ Auth: cercago.F(cercago.ToolSourceAuthParam{
+ "kind": "bar",
}),
Namespace: cercago.F("docs"),
- Tools: cercago.F([]cercago.HTTPToolDefinitionParam{map[string]interface{}{
- "name": "search",
- "description": "Search documents",
- "inputSchema": map[string]interface{}{
- "type": "object",
- },
- "endpoint": map[string]interface{}{
- "method": "GET",
- "url": "https://docs.example.com/search",
- },
+ Tools: cercago.F([]cercago.HTTPToolDefinitionParam{{
+ "name": "bar",
+ "description": "bar",
+ "inputSchema": "bar",
+ "endpoint": "bar",
}}),
- Type: cercago.F(cercago.EnvironmentToolSourceUpdateParamsBodyObjectTypeHTTP),
+ Type: cercago.F(cercago.ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestTypeHTTP),
Approval: cercago.F(cercago.ToolApprovalModeAlways),
Enabled: cercago.F(true),
- Execution: cercago.F[any](map[string]interface{}{
- "timeoutMs": 10000,
- "maxAttempts": 3,
- "retryMode": "safe_only",
+ Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
+ "timeoutMs": "bar",
+ "maxAttempts": "bar",
+ "retryMode": "bar",
}),
},
},
@@ -144,7 +134,7 @@ func TestEnvironmentToolSourceUpdateWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentToolSourceListWithOptionalParams(t *testing.T) {
+func TestToolSourceListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -156,10 +146,10 @@ func TestEnvironmentToolSourceListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.ToolSources.List(
+ _, err := client.ToolSources.List(
context.TODO(),
- "env_abc123",
- cercago.EnvironmentToolSourceListParams{
+ "fleet_abc123",
+ cercago.ToolSourceListParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
},
@@ -173,7 +163,7 @@ func TestEnvironmentToolSourceListWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentToolSourceDelete(t *testing.T) {
+func TestToolSourceDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -185,9 +175,9 @@ func TestEnvironmentToolSourceDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- err := client.Environments.ToolSources.Delete(
+ err := client.ToolSources.Delete(
context.TODO(),
- "env_abc123",
+ "fleet_abc123",
"toolsrc_abc123",
)
if err != nil {
@@ -198,3 +188,25 @@ func TestEnvironmentToolSourceDelete(t *testing.T) {
t.Fatalf("err should be nil: %s", err.Error())
}
}
+
+func TestToolSourceListForAgent(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.ToolSources.ListForAgent(context.TODO(), "agent_abc123")
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
diff --git a/usage_test.go b/usage_test.go
index 0672632..f5fc7c5 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -24,10 +24,10 @@ func TestUsage(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- thread, err := client.Cells.Threads.New(
+ thread, err := client.Threads.New(
context.TODO(),
- "cell_abc123",
- cercago.CellThreadNewParams{
+ "agent_abc123",
+ cercago.ThreadNewParams{
UserMessage: cercago.F("What's on my calendar today?"),
},
)
diff --git a/webhook.go b/webhook.go
new file mode 100644
index 0000000..b8d0876
--- /dev/null
+++ b/webhook.go
@@ -0,0 +1,355 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/url"
+ "slices"
+
+ "github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
+ "github.com/matrices/cerca-go/internal/requestconfig"
+ "github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+)
+
+// WebhookService contains methods and other services that help with interacting
+// with the cerca API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewWebhookService] method instead.
+type WebhookService struct {
+ Options []option.RequestOption
+}
+
+// NewWebhookService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewWebhookService(opts ...option.RequestOption) (r *WebhookService) {
+ r = &WebhookService{}
+ r.Options = opts
+ return
+}
+
+func (r *WebhookService) New(ctx context.Context, fleetID string, body WebhookNewParams, opts ...option.RequestOption) (res *WebhookSubscriptionCreated, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/webhooks", fleetID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *WebhookService) Get(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookSubscription, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ if webhookID == "" {
+ err = errors.New("missing required webhookId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/webhooks/%s", fleetID, webhookID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *WebhookService) Update(ctx context.Context, fleetID string, webhookID string, body WebhookUpdateParams, opts ...option.RequestOption) (res *WebhookSubscription, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ if webhookID == "" {
+ err = errors.New("missing required webhookId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/webhooks/%s", fleetID, webhookID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
+ return res, err
+}
+
+func (r *WebhookService) List(ctx context.Context, fleetID string, query WebhookListParams, opts ...option.RequestOption) (res *pagination.SubscriptionsCursorPage[WebhookSubscription], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/webhooks", fleetID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+func (r *WebhookService) ListAutoPaging(ctx context.Context, fleetID string, query WebhookListParams, opts ...option.RequestOption) *pagination.SubscriptionsCursorPageAutoPager[WebhookSubscription] {
+ return pagination.NewSubscriptionsCursorPageAutoPager(r.List(ctx, fleetID, query, opts...))
+}
+
+func (r *WebhookService) Delete(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (err error) {
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return err
+ }
+ if webhookID == "" {
+ err = errors.New("missing required webhookId parameter")
+ return err
+ }
+ path := fmt.Sprintf("fleets/%s/webhooks/%s", fleetID, webhookID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
+ return err
+}
+
+func (r *WebhookService) Rotate(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookSubscriptionCreated, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ if webhookID == "" {
+ err = errors.New("missing required webhookId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/webhooks/%s/rotate", fleetID, webhookID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
+ return res, err
+}
+
+func (r *WebhookService) Test(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookTestResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ if webhookID == "" {
+ err = errors.New("missing required webhookId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/webhooks/%s/test", fleetID, webhookID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
+ return res, err
+}
+
+type WebhookEventType string
+
+const (
+ WebhookEventTypeAgentCreated WebhookEventType = "agent.created"
+ WebhookEventTypeAgentUpdated WebhookEventType = "agent.updated"
+ WebhookEventTypeAgentDeleted WebhookEventType = "agent.deleted"
+ WebhookEventTypeThreadCreated WebhookEventType = "thread.created"
+ WebhookEventTypeThreadStatusChanged WebhookEventType = "thread.status.changed"
+ WebhookEventTypeThreadCompleted WebhookEventType = "thread.completed"
+ WebhookEventTypeThreadFailed WebhookEventType = "thread.failed"
+ WebhookEventTypeTurnCreated WebhookEventType = "turn.created"
+ WebhookEventTypeTurnCompleted WebhookEventType = "turn.completed"
+ WebhookEventTypeTurnFailed WebhookEventType = "turn.failed"
+ WebhookEventTypeMessageCreated WebhookEventType = "message.created"
+ WebhookEventTypeApprovalRequested WebhookEventType = "approval.requested"
+ WebhookEventTypeApprovalResolved WebhookEventType = "approval.resolved"
+ WebhookEventTypeApprovalGranted WebhookEventType = "approval.granted"
+ WebhookEventTypeScheduleCreated WebhookEventType = "schedule.created"
+ WebhookEventTypeScheduleDeleted WebhookEventType = "schedule.deleted"
+ WebhookEventTypeScheduleTriggered WebhookEventType = "schedule.triggered"
+ WebhookEventTypeConnectionAttached WebhookEventType = "connection.attached"
+ WebhookEventTypeConnectionDetached WebhookEventType = "connection.detached"
+ WebhookEventTypeWebhookTest WebhookEventType = "webhook.test"
+)
+
+func (r WebhookEventType) IsKnown() bool {
+ switch r {
+ case WebhookEventTypeAgentCreated, WebhookEventTypeAgentUpdated, WebhookEventTypeAgentDeleted, WebhookEventTypeThreadCreated, WebhookEventTypeThreadStatusChanged, WebhookEventTypeThreadCompleted, WebhookEventTypeThreadFailed, WebhookEventTypeTurnCreated, WebhookEventTypeTurnCompleted, WebhookEventTypeTurnFailed, WebhookEventTypeMessageCreated, WebhookEventTypeApprovalRequested, WebhookEventTypeApprovalResolved, WebhookEventTypeApprovalGranted, WebhookEventTypeScheduleCreated, WebhookEventTypeScheduleDeleted, WebhookEventTypeScheduleTriggered, WebhookEventTypeConnectionAttached, WebhookEventTypeConnectionDetached, WebhookEventTypeWebhookTest:
+ return true
+ }
+ return false
+}
+
+// Webhook subscription metadata returned by list, get, and update. The one-time
+// signing secret is not returned here.
+type WebhookSubscription struct {
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ Events []WebhookEventType `json:"events" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ URL string `json:"url" api:"required"`
+ JSON webhookSubscriptionJSON `json:"-"`
+}
+
+// webhookSubscriptionJSON contains the JSON metadata for the struct
+// [WebhookSubscription]
+type webhookSubscriptionJSON struct {
+ ID apijson.Field
+ CreatedAt apijson.Field
+ Enabled apijson.Field
+ Events apijson.Field
+ FleetID apijson.Field
+ UpdatedAt apijson.Field
+ URL apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *WebhookSubscription) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r webhookSubscriptionJSON) RawJSON() string {
+ return r.raw
+}
+
+// Webhook subscription response for create and rotate. Includes the one-time
+// `secret` field.
+type WebhookSubscriptionCreated struct {
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ Events []WebhookEventType `json:"events" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ // One-time webhook signing secret returned only by create and rotate responses.
+ // The field name is `secret`.
+ Secret string `json:"secret" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ URL string `json:"url" api:"required"`
+ JSON webhookSubscriptionCreatedJSON `json:"-"`
+}
+
+// webhookSubscriptionCreatedJSON contains the JSON metadata for the struct
+// [WebhookSubscriptionCreated]
+type webhookSubscriptionCreatedJSON struct {
+ ID apijson.Field
+ CreatedAt apijson.Field
+ Enabled apijson.Field
+ Events apijson.Field
+ FleetID apijson.Field
+ Secret apijson.Field
+ UpdatedAt apijson.Field
+ URL apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *WebhookSubscriptionCreated) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r webhookSubscriptionCreatedJSON) RawJSON() string {
+ return r.raw
+}
+
+// `webhook.test` is reserved for the test endpoint and cannot be subscribed to.
+type WebhookSubscriptionEventType string
+
+const (
+ WebhookSubscriptionEventTypeAgentCreated WebhookSubscriptionEventType = "agent.created"
+ WebhookSubscriptionEventTypeAgentUpdated WebhookSubscriptionEventType = "agent.updated"
+ WebhookSubscriptionEventTypeAgentDeleted WebhookSubscriptionEventType = "agent.deleted"
+ WebhookSubscriptionEventTypeThreadCreated WebhookSubscriptionEventType = "thread.created"
+ WebhookSubscriptionEventTypeThreadStatusChanged WebhookSubscriptionEventType = "thread.status.changed"
+ WebhookSubscriptionEventTypeThreadCompleted WebhookSubscriptionEventType = "thread.completed"
+ WebhookSubscriptionEventTypeThreadFailed WebhookSubscriptionEventType = "thread.failed"
+ WebhookSubscriptionEventTypeTurnCreated WebhookSubscriptionEventType = "turn.created"
+ WebhookSubscriptionEventTypeTurnCompleted WebhookSubscriptionEventType = "turn.completed"
+ WebhookSubscriptionEventTypeTurnFailed WebhookSubscriptionEventType = "turn.failed"
+ WebhookSubscriptionEventTypeMessageCreated WebhookSubscriptionEventType = "message.created"
+ WebhookSubscriptionEventTypeApprovalRequested WebhookSubscriptionEventType = "approval.requested"
+ WebhookSubscriptionEventTypeApprovalResolved WebhookSubscriptionEventType = "approval.resolved"
+ WebhookSubscriptionEventTypeApprovalGranted WebhookSubscriptionEventType = "approval.granted"
+ WebhookSubscriptionEventTypeScheduleCreated WebhookSubscriptionEventType = "schedule.created"
+ WebhookSubscriptionEventTypeScheduleDeleted WebhookSubscriptionEventType = "schedule.deleted"
+ WebhookSubscriptionEventTypeScheduleTriggered WebhookSubscriptionEventType = "schedule.triggered"
+ WebhookSubscriptionEventTypeConnectionAttached WebhookSubscriptionEventType = "connection.attached"
+ WebhookSubscriptionEventTypeConnectionDetached WebhookSubscriptionEventType = "connection.detached"
+)
+
+func (r WebhookSubscriptionEventType) IsKnown() bool {
+ switch r {
+ case WebhookSubscriptionEventTypeAgentCreated, WebhookSubscriptionEventTypeAgentUpdated, WebhookSubscriptionEventTypeAgentDeleted, WebhookSubscriptionEventTypeThreadCreated, WebhookSubscriptionEventTypeThreadStatusChanged, WebhookSubscriptionEventTypeThreadCompleted, WebhookSubscriptionEventTypeThreadFailed, WebhookSubscriptionEventTypeTurnCreated, WebhookSubscriptionEventTypeTurnCompleted, WebhookSubscriptionEventTypeTurnFailed, WebhookSubscriptionEventTypeMessageCreated, WebhookSubscriptionEventTypeApprovalRequested, WebhookSubscriptionEventTypeApprovalResolved, WebhookSubscriptionEventTypeApprovalGranted, WebhookSubscriptionEventTypeScheduleCreated, WebhookSubscriptionEventTypeScheduleDeleted, WebhookSubscriptionEventTypeScheduleTriggered, WebhookSubscriptionEventTypeConnectionAttached, WebhookSubscriptionEventTypeConnectionDetached:
+ return true
+ }
+ return false
+}
+
+type WebhookTestResponse struct {
+ Error string `json:"error" api:"required,nullable"`
+ StatusCode int64 `json:"statusCode" api:"required,nullable"`
+ Success bool `json:"success" api:"required"`
+ JSON webhookTestResponseJSON `json:"-"`
+}
+
+// webhookTestResponseJSON contains the JSON metadata for the struct
+// [WebhookTestResponse]
+type webhookTestResponseJSON struct {
+ Error apijson.Field
+ StatusCode apijson.Field
+ Success apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *WebhookTestResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r webhookTestResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type WebhookNewParams struct {
+ // HTTPS endpoint that will receive webhook deliveries.
+ URL param.Field[string] `json:"url" api:"required" format:"uri"`
+ // Event names to deliver. Omit to subscribe to all non-test events.
+ Events param.Field[[]WebhookSubscriptionEventType] `json:"events"`
+}
+
+func (r WebhookNewParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type WebhookUpdateParams struct {
+ // Whether deliveries are enabled for this subscription.
+ Enabled param.Field[bool] `json:"enabled"`
+ // Event names to deliver. Omit to subscribe to all non-test events.
+ Events param.Field[[]WebhookSubscriptionEventType] `json:"events"`
+ // HTTPS endpoint that will receive webhook deliveries.
+ URL param.Field[string] `json:"url" format:"uri"`
+}
+
+func (r WebhookUpdateParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type WebhookListParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [WebhookListParams]'s query parameters as `url.Values`.
+func (r WebhookListParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
diff --git a/environmentwebhook_test.go b/webhook_test.go
similarity index 79%
rename from environmentwebhook_test.go
rename to webhook_test.go
index 891f2bc..e880772 100644
--- a/environmentwebhook_test.go
+++ b/webhook_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestEnvironmentWebhookNewWithOptionalParams(t *testing.T) {
+func TestWebhookNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,12 +25,12 @@ func TestEnvironmentWebhookNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.Webhooks.New(
+ _, err := client.Webhooks.New(
context.TODO(),
- "env_abc123",
- cercago.EnvironmentWebhookNewParams{
+ "fleet_abc123",
+ cercago.WebhookNewParams{
URL: cercago.F("https://example.com/webhook"),
- Events: cercago.F([]cercago.WebhookSubscriptionEventType{cercago.WebhookSubscriptionEventTypeCellCreated}),
+ Events: cercago.F([]cercago.WebhookSubscriptionEventType{cercago.WebhookSubscriptionEventTypeAgentCreated}),
},
)
if err != nil {
@@ -42,7 +42,7 @@ func TestEnvironmentWebhookNewWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentWebhookGet(t *testing.T) {
+func TestWebhookGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -54,9 +54,9 @@ func TestEnvironmentWebhookGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.Webhooks.Get(
+ _, err := client.Webhooks.Get(
context.TODO(),
- "env_abc123",
+ "fleet_abc123",
"webhook_abc123",
)
if err != nil {
@@ -68,7 +68,7 @@ func TestEnvironmentWebhookGet(t *testing.T) {
}
}
-func TestEnvironmentWebhookUpdateWithOptionalParams(t *testing.T) {
+func TestWebhookUpdateWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -80,13 +80,13 @@ func TestEnvironmentWebhookUpdateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.Webhooks.Update(
+ _, err := client.Webhooks.Update(
context.TODO(),
- "env_abc123",
+ "fleet_abc123",
"webhook_abc123",
- cercago.EnvironmentWebhookUpdateParams{
+ cercago.WebhookUpdateParams{
Enabled: cercago.F(true),
- Events: cercago.F([]cercago.WebhookSubscriptionEventType{cercago.WebhookSubscriptionEventTypeCellCreated}),
+ Events: cercago.F([]cercago.WebhookSubscriptionEventType{cercago.WebhookSubscriptionEventTypeAgentCreated}),
URL: cercago.F("https://example.com/webhook"),
},
)
@@ -99,7 +99,7 @@ func TestEnvironmentWebhookUpdateWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentWebhookListWithOptionalParams(t *testing.T) {
+func TestWebhookListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -111,10 +111,10 @@ func TestEnvironmentWebhookListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.Webhooks.List(
+ _, err := client.Webhooks.List(
context.TODO(),
- "env_abc123",
- cercago.EnvironmentWebhookListParams{
+ "fleet_abc123",
+ cercago.WebhookListParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
},
@@ -128,7 +128,7 @@ func TestEnvironmentWebhookListWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentWebhookDelete(t *testing.T) {
+func TestWebhookDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -140,9 +140,9 @@ func TestEnvironmentWebhookDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- err := client.Environments.Webhooks.Delete(
+ err := client.Webhooks.Delete(
context.TODO(),
- "env_abc123",
+ "fleet_abc123",
"webhook_abc123",
)
if err != nil {
@@ -154,7 +154,7 @@ func TestEnvironmentWebhookDelete(t *testing.T) {
}
}
-func TestEnvironmentWebhookRotate(t *testing.T) {
+func TestWebhookRotate(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -166,9 +166,9 @@ func TestEnvironmentWebhookRotate(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.Webhooks.Rotate(
+ _, err := client.Webhooks.Rotate(
context.TODO(),
- "env_abc123",
+ "fleet_abc123",
"webhook_abc123",
)
if err != nil {
@@ -180,7 +180,7 @@ func TestEnvironmentWebhookRotate(t *testing.T) {
}
}
-func TestEnvironmentWebhookTest(t *testing.T) {
+func TestWebhookTest(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -192,9 +192,9 @@ func TestEnvironmentWebhookTest(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.Webhooks.Test(
+ _, err := client.Webhooks.Test(
context.TODO(),
- "env_abc123",
+ "fleet_abc123",
"webhook_abc123",
)
if err != nil {
From f47086d3f513b36c78f103fad99017bd27048c3b Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 24 Apr 2026 16:27:49 +0000
Subject: [PATCH 03/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index 2d71c51..9ff1262 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-1ca6943fcf7d9c2630357db20c3d1eb4495d4ecab907f4e20f62508175b8ae5c.yml
openapi_spec_hash: 9c2f51f5495c1b592e96a9e0c9969f46
-config_hash: 5cc3f8a35eb3b078cbd5ebc45d48e6f6
+config_hash: 184329637e8b68ece474ec1f88a5cf99
From fe6da53d6f52717356269f15a4af49e5b8ad150a Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 24 Apr 2026 16:28:18 +0000
Subject: [PATCH 04/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index 9ff1262..b46ac39 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-1ca6943fcf7d9c2630357db20c3d1eb4495d4ecab907f4e20f62508175b8ae5c.yml
openapi_spec_hash: 9c2f51f5495c1b592e96a9e0c9969f46
-config_hash: 184329637e8b68ece474ec1f88a5cf99
+config_hash: 26dd172ce5a136618892793f4f9e9412
From 28d997436431eab98e9a0ede4b3a5fb7475e4500 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 24 Apr 2026 16:31:49 +0000
Subject: [PATCH 05/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index b46ac39..0287a32 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-1ca6943fcf7d9c2630357db20c3d1eb4495d4ecab907f4e20f62508175b8ae5c.yml
openapi_spec_hash: 9c2f51f5495c1b592e96a9e0c9969f46
-config_hash: 26dd172ce5a136618892793f4f9e9412
+config_hash: 9105f134a32978d1d1bfd7c6b30c2a3b
From 253d5a5f91c50b5ff1b6a8b3bce0efca303b8d74 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 24 Apr 2026 16:39:20 +0000
Subject: [PATCH 06/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index 0287a32..c80659d 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-1ca6943fcf7d9c2630357db20c3d1eb4495d4ecab907f4e20f62508175b8ae5c.yml
openapi_spec_hash: 9c2f51f5495c1b592e96a9e0c9969f46
-config_hash: 9105f134a32978d1d1bfd7c6b30c2a3b
+config_hash: 508cf41791dca90f0938c9ebd9bd7f0c
From 5264d8d2efdbf5b4b5d5ccc16b0442feaa1827b2 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Sun, 26 Apr 2026 02:31:46 +0000
Subject: [PATCH 07/29] feat(go): add default http client with timeout
---
client.go | 2 +-
default_http_client.go | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 default_http_client.go
diff --git a/client.go b/client.go
index 3eb19fc..95f1eae 100644
--- a/client.go
+++ b/client.go
@@ -40,7 +40,7 @@ type Client struct {
// DefaultClientOptions read from the environment (CERCA_API_KEY, CERCA_BASE_URL).
// This should be used to initialize new clients.
func DefaultClientOptions() []option.RequestOption {
- defaults := []option.RequestOption{option.WithEnvironmentProduction()}
+ defaults := []option.RequestOption{option.WithHTTPClient(defaultHTTPClient()), option.WithEnvironmentProduction()}
if o, ok := os.LookupEnv("CERCA_BASE_URL"); ok {
defaults = append(defaults, option.WithBaseURL(o))
}
diff --git a/default_http_client.go b/default_http_client.go
new file mode 100644
index 0000000..f729243
--- /dev/null
+++ b/default_http_client.go
@@ -0,0 +1,24 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "net/http"
+ "time"
+)
+
+// defaultResponseHeaderTimeout bounds the time between a fully written request
+// and the server's response headers. It does not apply to the response body,
+// so long-running streams are unaffected. Without this, a server that accepts
+// the connection but never responds would hang the request indefinitely.
+const defaultResponseHeaderTimeout = 10 * time.Minute
+
+// defaultHTTPClient returns an [*http.Client] used when the caller does not
+// supply one via [option.WithHTTPClient]. It clones [http.DefaultTransport]
+// and adds a [http.Transport.ResponseHeaderTimeout] so stuck connections
+// fail fast instead of compounding across retries.
+func defaultHTTPClient() *http.Client {
+ transport := http.DefaultTransport.(*http.Transport).Clone()
+ transport.ResponseHeaderTimeout = defaultResponseHeaderTimeout
+ return &http.Client{Transport: transport}
+}
From 5c6579f082703dbd457d333312c3d11eeb3ded86 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Tue, 28 Apr 2026 02:13:23 +0000
Subject: [PATCH 08/29] feat: support setting headers via env
---
client.go | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/client.go b/client.go
index 95f1eae..602dc44 100644
--- a/client.go
+++ b/client.go
@@ -7,6 +7,7 @@ import (
"net/http"
"os"
"slices"
+ "strings"
"github.com/matrices/cerca-go/internal/requestconfig"
"github.com/matrices/cerca-go/option"
@@ -47,6 +48,14 @@ func DefaultClientOptions() []option.RequestOption {
if o, ok := os.LookupEnv("CERCA_API_KEY"); ok {
defaults = append(defaults, option.WithAPIKey(o))
}
+ if o, ok := os.LookupEnv("CERCA_CUSTOM_HEADERS"); ok {
+ for _, line := range strings.Split(o, "\n") {
+ colon := strings.Index(line, ":")
+ if colon >= 0 {
+ defaults = append(defaults, option.WithHeader(strings.TrimSpace(line[:colon]), strings.TrimSpace(line[colon+1:])))
+ }
+ }
+ }
return defaults
}
From 5a087e900532c1fa53225b561ee603c9ebe5eec1 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Wed, 29 Apr 2026 23:34:44 +0000
Subject: [PATCH 09/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index c80659d..52158d4 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-1ca6943fcf7d9c2630357db20c3d1eb4495d4ecab907f4e20f62508175b8ae5c.yml
openapi_spec_hash: 9c2f51f5495c1b592e96a9e0c9969f46
-config_hash: 508cf41791dca90f0938c9ebd9bd7f0c
+config_hash: d55df93567c0e09fea6827066eeb10c1
From 8670a4e255e029af5600c5355ecc1054c43eceb0 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Wed, 29 Apr 2026 23:51:13 +0000
Subject: [PATCH 10/29] feat(api): manual updates
---
.stats.yml | 2 +-
agent.go | 2 +-
agent_test.go | 2 +-
schedule.go | 11 ++++++++---
schedule_test.go | 5 ++++-
shared/shared.go | 7 +++++--
thread.go | 21 ++++++++++++++++++---
thread_test.go | 3 +++
8 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index 52158d4..144c388 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-1ca6943fcf7d9c2630357db20c3d1eb4495d4ecab907f4e20f62508175b8ae5c.yml
-openapi_spec_hash: 9c2f51f5495c1b592e96a9e0c9969f46
+openapi_spec_hash: e8825a4209dfbf533407eef182184acf
config_hash: d55df93567c0e09fea6827066eeb10c1
diff --git a/agent.go b/agent.go
index d8063c9..277a47e 100644
--- a/agent.go
+++ b/agent.go
@@ -543,12 +543,12 @@ func (r AgentDeleteResponseSuccess) IsKnown() bool {
}
type AgentNewParams struct {
- UserID param.Field[string] `json:"userId" api:"required"`
Configuration param.Field[ConfigurationParam] `json:"configuration"`
FleetID param.Field[string] `json:"fleetId"`
// Arbitrary string metadata stored on an agent. Runtime enforces maximum key and
// value sizes.
Metadata param.Field[MetadataParam] `json:"metadata"`
+ UserID param.Field[string] `json:"userId"`
}
func (r AgentNewParams) MarshalJSON() (data []byte, err error) {
diff --git a/agent_test.go b/agent_test.go
index 53b3b6f..e04228f 100644
--- a/agent_test.go
+++ b/agent_test.go
@@ -27,7 +27,6 @@ func TestAgentNewWithOptionalParams(t *testing.T) {
option.WithAPIKey("My API Key"),
)
_, err := client.Agents.New(context.TODO(), cercago.AgentNewParams{
- UserID: cercago.F("userId"),
Configuration: cercago.F(cercago.ConfigurationParam{
Approvals: cercago.F(cercago.ApprovalPolicyParam{
TimeoutMs: cercago.F(0.000000),
@@ -43,6 +42,7 @@ func TestAgentNewWithOptionalParams(t *testing.T) {
Metadata: cercago.F(cercago.MetadataParam{
"project": "alpha",
}),
+ UserID: cercago.F("userId"),
})
if err != nil {
var apierr *cercago.Error
diff --git a/schedule.go b/schedule.go
index 1fa5ced..4801135 100644
--- a/schedule.go
+++ b/schedule.go
@@ -8,6 +8,7 @@ import (
"fmt"
"net/http"
"slices"
+ "time"
"github.com/matrices/cerca-go/internal/apijson"
"github.com/matrices/cerca-go/internal/param"
@@ -105,15 +106,16 @@ func (r *ScheduleService) Trigger(ctx context.Context, agentID string, scheduleI
type ScheduledThread struct {
ID string `json:"id" api:"required"`
CreatedAt string `json:"createdAt" api:"required"`
- Cron string `json:"cron" api:"required"`
Enabled bool `json:"enabled" api:"required"`
Name string `json:"name" api:"required"`
NextAt string `json:"nextAt" api:"required,nullable"`
Prompt string `json:"prompt" api:"required"`
Timezone string `json:"timezone" api:"required"`
UpdatedAt string `json:"updatedAt" api:"required"`
+ Cron string `json:"cron"`
Instructions string `json:"instructions"`
Model string `json:"model"`
+ RunAt time.Time `json:"runAt" format:"date-time"`
Tools []shared.ToolSpec `json:"tools"`
JSON scheduledThreadJSON `json:"-"`
}
@@ -122,15 +124,16 @@ type ScheduledThread struct {
type scheduledThreadJSON struct {
ID apijson.Field
CreatedAt apijson.Field
- Cron apijson.Field
Enabled apijson.Field
Name apijson.Field
NextAt apijson.Field
Prompt apijson.Field
Timezone apijson.Field
UpdatedAt apijson.Field
+ Cron apijson.Field
Instructions apijson.Field
Model apijson.Field
+ RunAt apijson.Field
Tools apijson.Field
raw string
ExtraFields map[string]apijson.Field
@@ -222,11 +225,12 @@ func (r scheduleTriggerResponseJSON) RawJSON() string {
}
type ScheduleNewParams struct {
- Cron param.Field[string] `json:"cron" api:"required"`
Name param.Field[string] `json:"name" api:"required"`
Prompt param.Field[string] `json:"prompt" api:"required"`
+ Cron param.Field[string] `json:"cron"`
Instructions param.Field[string] `json:"instructions"`
Model param.Field[string] `json:"model"`
+ RunAt param.Field[time.Time] `json:"runAt" format:"date-time"`
Timezone param.Field[string] `json:"timezone"`
Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
}
@@ -242,6 +246,7 @@ type ScheduleUpdateParams struct {
Model param.Field[string] `json:"model"`
Name param.Field[string] `json:"name"`
Prompt param.Field[string] `json:"prompt"`
+ RunAt param.Field[time.Time] `json:"runAt" format:"date-time"`
Timezone param.Field[string] `json:"timezone"`
Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
}
diff --git a/schedule_test.go b/schedule_test.go
index d40551d..7151f15 100644
--- a/schedule_test.go
+++ b/schedule_test.go
@@ -7,6 +7,7 @@ import (
"errors"
"os"
"testing"
+ "time"
"github.com/matrices/cerca-go"
"github.com/matrices/cerca-go/internal/testutil"
@@ -30,11 +31,12 @@ func TestScheduleNewWithOptionalParams(t *testing.T) {
context.TODO(),
"agent_abc123",
cercago.ScheduleNewParams{
- Cron: cercago.F("cron"),
Name: cercago.F("name"),
Prompt: cercago.F("prompt"),
+ Cron: cercago.F("cron"),
Instructions: cercago.F("instructions"),
Model: cercago.F("model"),
+ RunAt: cercago.F(time.Now()),
Timezone: cercago.F("timezone"),
Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
},
@@ -71,6 +73,7 @@ func TestScheduleUpdateWithOptionalParams(t *testing.T) {
Model: cercago.F("model"),
Name: cercago.F("name"),
Prompt: cercago.F("prompt"),
+ RunAt: cercago.F(time.Now()),
Timezone: cercago.F("timezone"),
Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
},
diff --git a/shared/shared.go b/shared/shared.go
index 46ae0a7..56671f6 100644
--- a/shared/shared.go
+++ b/shared/shared.go
@@ -22,13 +22,16 @@ func (r ApprovalMode) IsKnown() bool {
}
type ErrorResponse struct {
- Error string `json:"error" api:"required"`
- JSON errorResponseJSON `json:"-"`
+ Error string `json:"error" api:"required"`
+ // Stable machine-readable error code when the API can provide one.
+ Code string `json:"code"`
+ JSON errorResponseJSON `json:"-"`
}
// errorResponseJSON contains the JSON metadata for the struct [ErrorResponse]
type errorResponseJSON struct {
Error apijson.Field
+ Code apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
diff --git a/thread.go b/thread.go
index 3b577b8..cfe8a30 100644
--- a/thread.go
+++ b/thread.go
@@ -380,12 +380,14 @@ type Thread struct {
CompiledContext CompiledContext `json:"compiledContext" api:"required,nullable"`
CompletedAt string `json:"completedAt" api:"required,nullable"`
ComposedSystemPrompt string `json:"composedSystemPrompt" api:"required,nullable"`
- ContextWindow ContextWindow `json:"contextWindow" api:"required"`
+ ContextWindow ContextWindow `json:"contextWindow" api:"required,nullable"`
CreatedAt string `json:"createdAt" api:"required"`
Depth float64 `json:"depth" api:"required"`
Error string `json:"error" api:"required,nullable"`
+ HasMoreMessages bool `json:"hasMoreMessages" api:"required"`
Instructions string `json:"instructions" api:"required,nullable"`
LastTurnStatus ThreadLastTurnStatus `json:"lastTurnStatus" api:"required,nullable"`
+ MessageCursor float64 `json:"messageCursor" api:"required,nullable"`
Messages []Message `json:"messages" api:"required"`
Model string `json:"model" api:"required"`
ParentThreadID string `json:"parentThreadId" api:"required,nullable"`
@@ -398,10 +400,11 @@ type Thread struct {
// `closed` threads are terminal.
Status Status `json:"status" api:"required"`
SubThreads []ThreadSummary `json:"subThreads" api:"required"`
- ToolSnapshot []shared.ToolName `json:"toolSnapshot" api:"required"`
+ Tools []shared.ToolName `json:"tools" api:"required"`
Turns []Turn `json:"turns" api:"required"`
UpdatedAt string `json:"updatedAt" api:"required"`
UserMessage string `json:"userMessage" api:"required"`
+ ActiveTurnModel string `json:"activeTurnModel" api:"nullable"`
ExternalToolNamespaces ThreadExternalToolNamespacesUnion `json:"externalToolNamespaces"`
JSON threadJSON `json:"-"`
}
@@ -419,8 +422,10 @@ type threadJSON struct {
CreatedAt apijson.Field
Depth apijson.Field
Error apijson.Field
+ HasMoreMessages apijson.Field
Instructions apijson.Field
LastTurnStatus apijson.Field
+ MessageCursor apijson.Field
Messages apijson.Field
Model apijson.Field
ParentThreadID apijson.Field
@@ -430,10 +435,11 @@ type threadJSON struct {
ScheduleSeq apijson.Field
Status apijson.Field
SubThreads apijson.Field
- ToolSnapshot apijson.Field
+ Tools apijson.Field
Turns apijson.Field
UpdatedAt apijson.Field
UserMessage apijson.Field
+ ActiveTurnModel apijson.Field
ExternalToolNamespaces apijson.Field
raw string
ExtraFields map[string]apijson.Field
@@ -640,10 +646,19 @@ func (r ThreadNewParams) MarshalJSON() (data []byte, err error) {
}
type ThreadGetParams struct {
+ // Return messages newer than this sequence number. Mutually exclusive with
+ // `beforeSeq`.
+ AfterSeq param.Field[string] `query:"afterSeq"`
+ // Return messages older than this sequence number. Mutually exclusive with
+ // `afterSeq`.
+ BeforeSeq param.Field[string] `query:"beforeSeq"`
// When true, includes debug-only compiled context fields.
Debug param.Field[ThreadGetParamsDebug] `query:"debug"`
// When true, includes message content in the thread detail.
IncludeMessages param.Field[ThreadGetParamsIncludeMessages] `query:"includeMessages"`
+ // Maximum number of messages to include. Set to 0 to return metadata without
+ // messages.
+ MessageLimit param.Field[string] `query:"messageLimit"`
}
// URLQuery serializes [ThreadGetParams]'s query parameters as `url.Values`.
diff --git a/thread_test.go b/thread_test.go
index 184488c..0fbd638 100644
--- a/thread_test.go
+++ b/thread_test.go
@@ -63,8 +63,11 @@ func TestThreadGetWithOptionalParams(t *testing.T) {
"agent_abc123",
"thread_abc123",
cercago.ThreadGetParams{
+ AfterSeq: cercago.F("42"),
+ BeforeSeq: cercago.F("42"),
Debug: cercago.F(cercago.ThreadGetParamsDebugFalse),
IncludeMessages: cercago.F(cercago.ThreadGetParamsIncludeMessagesTrue),
+ MessageLimit: cercago.F("50"),
},
)
if err != nil {
From 9bf0c17e9b52b1d0a2b36155bb974416ad00e896 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 02:33:06 +0000
Subject: [PATCH 11/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index 144c388..36f5c54 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 66
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5%2Fcerca-1ca6943fcf7d9c2630357db20c3d1eb4495d4ecab907f4e20f62508175b8ae5c.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-6338f21488a9e712e2f5cf43b2687c51c88c4b11c05239bc1aa86db643417b74.yml
openapi_spec_hash: e8825a4209dfbf533407eef182184acf
config_hash: d55df93567c0e09fea6827066eeb10c1
From d7e1bc066e9d6e1168070a1bb0b94159d161a98c Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 19:00:01 +0000
Subject: [PATCH 12/29] feat(api): api update
---
.stats.yml | 8 +-
README.md | 2 +-
agent.go | 422 +++-
agent_test.go | 22 +
aliases.go | 6 +-
api.md | 112 +-
approvalgrant.go | 5 +
approval.go => approvalrequest.go | 80 +-
approval_test.go => approvalrequest_test.go | 16 +-
auth.go | 3 +
client.go | 44 +-
connection.go | 478 ++++-
connection_test.go | 93 +-
context.go | 7 +
credential.go | 223 --
credential_test.go | 99 -
event.go | 2031 ++++++++++++++++++-
log.go | 179 --
log_test.go | 73 -
model.go | 1 +
oauth.go | 6 +-
oauth_test.go | 4 +-
packages/pagination/pagination.go | 151 +-
sandbox.go | 3 +
schedule.go | 91 +-
schedule_test.go | 4 +-
thread.go | 526 ++++-
thread_test.go | 11 +-
tool.go | 1734 +++++++++++++++-
tool_test.go | 210 +-
toolsource.go | 665 ------
toolsource_test.go | 212 --
usage_test.go | 2 +-
webhook.go | 8 +
34 files changed, 5489 insertions(+), 2042 deletions(-)
rename approval.go => approvalrequest.go (60%)
rename approval_test.go => approvalrequest_test.go (76%)
delete mode 100644 credential.go
delete mode 100644 credential_test.go
delete mode 100644 log.go
delete mode 100644 log_test.go
delete mode 100644 toolsource.go
delete mode 100644 toolsource_test.go
diff --git a/.stats.yml b/.stats.yml
index 36f5c54..c4eee12 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 66
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-6338f21488a9e712e2f5cf43b2687c51c88c4b11c05239bc1aa86db643417b74.yml
-openapi_spec_hash: e8825a4209dfbf533407eef182184acf
-config_hash: d55df93567c0e09fea6827066eeb10c1
+configured_endpoints: 63
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-faba937c111404b92c6ad3e74fc0184ceee1ac22171c59c191f0ada6e90b8e18.yml
+openapi_spec_hash: dc483f9e464f4ba657bab48df3fa09fe
+config_hash: 760e5624c524327bcfb49e54b9e3a6e2
diff --git a/README.md b/README.md
index 1591844..b576cd2 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ func main() {
context.TODO(),
"agent_abc123",
cercago.ThreadNewParams{
- UserMessage: cercago.F("What's on my calendar today?"),
+ Message: cercago.F("What's on my calendar today?"),
},
)
if err != nil {
diff --git a/agent.go b/agent.go
index 277a47e..ff02137 100644
--- a/agent.go
+++ b/agent.go
@@ -40,6 +40,7 @@ func NewAgentService(opts ...option.RequestOption) (r *AgentService) {
return
}
+// Agents
func (r *AgentService) New(ctx context.Context, body AgentNewParams, opts ...option.RequestOption) (res *Agent, err error) {
opts = slices.Concat(r.Options, opts)
path := "agents"
@@ -47,6 +48,7 @@ func (r *AgentService) New(ctx context.Context, body AgentNewParams, opts ...opt
return res, err
}
+// Agent
func (r *AgentService) Get(ctx context.Context, agentID string, opts ...option.RequestOption) (res *Agent, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -58,6 +60,7 @@ func (r *AgentService) Get(ctx context.Context, agentID string, opts ...option.R
return res, err
}
+// Agent
func (r *AgentService) Update(ctx context.Context, agentID string, body AgentUpdateParams, opts ...option.RequestOption) (res *Agent, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -69,6 +72,7 @@ func (r *AgentService) Update(ctx context.Context, agentID string, body AgentUpd
return res, err
}
+// Agents
func (r *AgentService) List(ctx context.Context, query AgentListParams, opts ...option.RequestOption) (res *pagination.AgentsCursorPage[AgentSummary], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -86,10 +90,12 @@ func (r *AgentService) List(ctx context.Context, query AgentListParams, opts ...
return res, nil
}
+// Agents
func (r *AgentService) ListAutoPaging(ctx context.Context, query AgentListParams, opts ...option.RequestOption) *pagination.AgentsCursorPageAutoPager[AgentSummary] {
return pagination.NewAgentsCursorPageAutoPager(r.List(ctx, query, opts...))
}
+// Agent
func (r *AgentService) Delete(ctx context.Context, agentID string, opts ...option.RequestOption) (res *AgentDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -101,6 +107,19 @@ func (r *AgentService) Delete(ctx context.Context, agentID string, opts ...optio
return res, err
}
+// Tools
+func (r *AgentService) ListTools(ctx context.Context, agentID string, opts ...option.RequestOption) (res *AgentListToolsResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/tools", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// Config
func (r *AgentService) GetConfig(ctx context.Context, agentID string, opts ...option.RequestOption) (res *EffectiveConfiguration, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -112,6 +131,7 @@ func (r *AgentService) GetConfig(ctx context.Context, agentID string, opts ...op
return res, err
}
+// Metadata
func (r *AgentService) UpdateMetadata(ctx context.Context, agentID string, body AgentUpdateMetadataParams, opts ...option.RequestOption) (res *Agent, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -235,11 +255,13 @@ func (r ApprovalPolicyParam) MarshalJSON() (data []byte, err error) {
}
type Configuration struct {
- Approvals ApprovalPolicy `json:"approvals"`
- DefaultModel string `json:"defaultModel"`
- Instructions string `json:"instructions"`
- Tools []shared.ToolSpec `json:"tools"`
- JSON configurationJSON `json:"-"`
+ Approvals ApprovalPolicy `json:"approvals"`
+ DefaultModel string `json:"defaultModel"`
+ Instructions string `json:"instructions"`
+ // Agent tool allowlist. These tools are subject to fleet defaults and locks, and
+ // thread or turn requests may only narrow the resulting effective tools.
+ Tools []shared.ToolSpec `json:"tools"`
+ JSON configurationJSON `json:"-"`
}
// configurationJSON contains the JSON metadata for the struct [Configuration]
@@ -261,10 +283,12 @@ func (r configurationJSON) RawJSON() string {
}
type ConfigurationParam struct {
- Approvals param.Field[ApprovalPolicyParam] `json:"approvals"`
- DefaultModel param.Field[string] `json:"defaultModel"`
- Instructions param.Field[string] `json:"instructions"`
- Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+ Approvals param.Field[ApprovalPolicyParam] `json:"approvals"`
+ DefaultModel param.Field[string] `json:"defaultModel"`
+ Instructions param.Field[string] `json:"instructions"`
+ // Agent tool allowlist. These tools are subject to fleet defaults and locks, and
+ // thread or turn requests may only narrow the resulting effective tools.
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
}
func (r ConfigurationParam) MarshalJSON() (data []byte, err error) {
@@ -288,15 +312,107 @@ func (r ConfigurationFieldName) IsKnown() bool {
return false
}
+// An external provider or tool-source tool currently available to the agent.
+type DiscoveredTool struct {
+ Approval DiscoveredToolApproval `json:"approval" api:"required"`
+ Category DiscoveredToolCategory `json:"category" api:"required"`
+ Description string `json:"description" api:"required"`
+ // JSON Schema object describing tool input parameters.
+ InputSchema map[string]interface{} `json:"inputSchema" api:"required"`
+ Name string `json:"name" api:"required"`
+ Origin DiscoveredToolOrigin `json:"origin" api:"required"`
+ Source string `json:"source" api:"required"`
+ AccountLabel string `json:"accountLabel"`
+ ConnectionID string `json:"connectionId"`
+ ConnectionMetadata ToolConnectionMetadata `json:"connectionMetadata"`
+ SourceID string `json:"sourceId"`
+ SourceVersion float64 `json:"sourceVersion"`
+ JSON discoveredToolJSON `json:"-"`
+}
+
+// discoveredToolJSON contains the JSON metadata for the struct [DiscoveredTool]
+type discoveredToolJSON struct {
+ Approval apijson.Field
+ Category apijson.Field
+ Description apijson.Field
+ InputSchema apijson.Field
+ Name apijson.Field
+ Origin apijson.Field
+ Source apijson.Field
+ AccountLabel apijson.Field
+ ConnectionID apijson.Field
+ ConnectionMetadata apijson.Field
+ SourceID apijson.Field
+ SourceVersion apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *DiscoveredTool) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r discoveredToolJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r DiscoveredTool) implementsTool() {}
+
+type DiscoveredToolApproval string
+
+const (
+ DiscoveredToolApprovalAlways DiscoveredToolApproval = "always"
+ DiscoveredToolApprovalNever DiscoveredToolApproval = "never"
+)
+
+func (r DiscoveredToolApproval) IsKnown() bool {
+ switch r {
+ case DiscoveredToolApprovalAlways, DiscoveredToolApprovalNever:
+ return true
+ }
+ return false
+}
+
+type DiscoveredToolCategory string
+
+const (
+ DiscoveredToolCategoryExternal DiscoveredToolCategory = "external"
+)
+
+func (r DiscoveredToolCategory) IsKnown() bool {
+ switch r {
+ case DiscoveredToolCategoryExternal:
+ return true
+ }
+ return false
+}
+
+type DiscoveredToolOrigin string
+
+const (
+ DiscoveredToolOriginBuiltin DiscoveredToolOrigin = "builtin"
+ DiscoveredToolOriginToolSource DiscoveredToolOrigin = "tool_source"
+)
+
+func (r DiscoveredToolOrigin) IsKnown() bool {
+ switch r {
+ case DiscoveredToolOriginBuiltin, DiscoveredToolOriginToolSource:
+ return true
+ }
+ return false
+}
+
type EffectiveConfiguration struct {
Approvals EffectiveConfigurationApprovals `json:"approvals" api:"required"`
ApprovalsWritableByAgent bool `json:"approvalsWritableByAgent" api:"required"`
DefaultModel string `json:"defaultModel" api:"required"`
LockedByFleet []ConfigurationFieldName `json:"lockedByFleet" api:"required"`
ResolvedFromFleet []ConfigurationFieldName `json:"resolvedFromFleet" api:"required"`
- Tools []shared.ToolName `json:"tools" api:"required"`
- Instructions string `json:"instructions"`
- JSON effectiveConfigurationJSON `json:"-"`
+ // Effective internal runtime tools after applying fleet defaults, fleet locks, and
+ // the agent allowlist.
+ Tools []shared.ToolName `json:"tools" api:"required"`
+ Instructions string `json:"instructions"`
+ JSON effectiveConfigurationJSON `json:"-"`
}
// effectiveConfigurationJSON contains the JSON metadata for the struct
@@ -396,14 +512,16 @@ type ExecutionPrincipalUnion interface {
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*ExecutionPrincipalUnion)(nil)).Elem(),
- "",
+ "kind",
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ExecutionPrincipalUserExecutionPrincipal{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ExecutionPrincipalUserExecutionPrincipal{}),
+ DiscriminatorValue: "user",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ExecutionPrincipalAPIKeyExecutionPrincipal{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ExecutionPrincipalAPIKeyExecutionPrincipal{}),
+ DiscriminatorValue: "apiKey",
},
)
}
@@ -507,6 +625,250 @@ type Metadata map[string]string
type MetadataParam map[string]string
+type SourceWarning struct {
+ Message string `json:"message" api:"required"`
+ Source string `json:"source" api:"required"`
+ SourceID string `json:"sourceId"`
+ JSON sourceWarningJSON `json:"-"`
+}
+
+// sourceWarningJSON contains the JSON metadata for the struct [SourceWarning]
+type sourceWarningJSON struct {
+ Message apijson.Field
+ Source apijson.Field
+ SourceID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SourceWarning) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r sourceWarningJSON) RawJSON() string {
+ return r.raw
+}
+
+// A unified available tool entry. Runtime tools include requiresApproval; external
+// tools include approval.
+type Tool struct {
+ Category ToolCategory `json:"category" api:"required"`
+ Description string `json:"description" api:"required"`
+ // This field can have the runtime type of [shared.JsonObject],
+ // [map[string]interface{}].
+ InputSchema interface{} `json:"inputSchema" api:"required"`
+ Name shared.ToolName `json:"name" api:"required"`
+ AccountLabel string `json:"accountLabel"`
+ Approval ToolApproval `json:"approval"`
+ ApprovalSource ToolApprovalSource `json:"approvalSource"`
+ ConnectionID string `json:"connectionId"`
+ ConnectionMetadata ToolConnectionMetadata `json:"connectionMetadata"`
+ Origin ToolOrigin `json:"origin"`
+ RequiresApproval bool `json:"requiresApproval"`
+ Source string `json:"source"`
+ SourceID string `json:"sourceId"`
+ SourceVersion float64 `json:"sourceVersion"`
+ JSON toolJSON `json:"-"`
+ union ToolUnion
+}
+
+// toolJSON contains the JSON metadata for the struct [Tool]
+type toolJSON struct {
+ Category apijson.Field
+ Description apijson.Field
+ InputSchema apijson.Field
+ Name apijson.Field
+ AccountLabel apijson.Field
+ Approval apijson.Field
+ ApprovalSource apijson.Field
+ ConnectionID apijson.Field
+ ConnectionMetadata apijson.Field
+ Origin apijson.Field
+ RequiresApproval apijson.Field
+ Source apijson.Field
+ SourceID apijson.Field
+ SourceVersion apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r toolJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *Tool) UnmarshalJSON(data []byte) (err error) {
+ *r = Tool{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [ToolUnion] interface which you can cast to the specific types
+// for more type safety.
+//
+// Possible runtime types of the union are [ToolDescriptor], [DiscoveredTool].
+func (r Tool) AsUnion() ToolUnion {
+ return r.union
+}
+
+// A unified available tool entry. Runtime tools include requiresApproval; external
+// tools include approval.
+//
+// Union satisfied by [ToolDescriptor] or [DiscoveredTool].
+type ToolUnion interface {
+ implementsTool()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ToolUnion)(nil)).Elem(),
+ "category",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolDescriptor{}),
+ DiscriminatorValue: "builtIn",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolDescriptor{}),
+ DiscriminatorValue: "configurable",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(DiscoveredTool{}),
+ DiscriminatorValue: "external",
+ },
+ )
+}
+
+type ToolCategory string
+
+const (
+ ToolCategoryBuiltIn ToolCategory = "builtIn"
+ ToolCategoryConfigurable ToolCategory = "configurable"
+ ToolCategoryExternal ToolCategory = "external"
+)
+
+func (r ToolCategory) IsKnown() bool {
+ switch r {
+ case ToolCategoryBuiltIn, ToolCategoryConfigurable, ToolCategoryExternal:
+ return true
+ }
+ return false
+}
+
+type ToolApproval string
+
+const (
+ ToolApprovalAlways ToolApproval = "always"
+ ToolApprovalNever ToolApproval = "never"
+)
+
+func (r ToolApproval) IsKnown() bool {
+ switch r {
+ case ToolApprovalAlways, ToolApprovalNever:
+ return true
+ }
+ return false
+}
+
+type ToolApprovalSource string
+
+const (
+ ToolApprovalSourceAgent ToolApprovalSource = "agent"
+ ToolApprovalSourceEnv ToolApprovalSource = "env"
+ ToolApprovalSourceCatalog ToolApprovalSource = "catalog"
+)
+
+func (r ToolApprovalSource) IsKnown() bool {
+ switch r {
+ case ToolApprovalSourceAgent, ToolApprovalSourceEnv, ToolApprovalSourceCatalog:
+ return true
+ }
+ return false
+}
+
+type ToolOrigin string
+
+const (
+ ToolOriginBuiltin ToolOrigin = "builtin"
+ ToolOriginToolSource ToolOrigin = "tool_source"
+)
+
+func (r ToolOrigin) IsKnown() bool {
+ switch r {
+ case ToolOriginBuiltin, ToolOriginToolSource:
+ return true
+ }
+ return false
+}
+
+// A built-in or configurable runtime tool currently available to the agent.
+type ToolDescriptor struct {
+ ApprovalSource ToolDescriptorApprovalSource `json:"approvalSource" api:"required"`
+ Category ToolDescriptorCategory `json:"category" api:"required"`
+ Description string `json:"description" api:"required"`
+ InputSchema shared.JsonObject `json:"inputSchema" api:"required"`
+ Name shared.ToolName `json:"name" api:"required"`
+ RequiresApproval bool `json:"requiresApproval" api:"required"`
+ JSON toolDescriptorJSON `json:"-"`
+}
+
+// toolDescriptorJSON contains the JSON metadata for the struct [ToolDescriptor]
+type toolDescriptorJSON struct {
+ ApprovalSource apijson.Field
+ Category apijson.Field
+ Description apijson.Field
+ InputSchema apijson.Field
+ Name apijson.Field
+ RequiresApproval apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ToolDescriptor) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r toolDescriptorJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ToolDescriptor) implementsTool() {}
+
+type ToolDescriptorApprovalSource string
+
+const (
+ ToolDescriptorApprovalSourceAgent ToolDescriptorApprovalSource = "agent"
+ ToolDescriptorApprovalSourceEnv ToolDescriptorApprovalSource = "env"
+ ToolDescriptorApprovalSourceCatalog ToolDescriptorApprovalSource = "catalog"
+)
+
+func (r ToolDescriptorApprovalSource) IsKnown() bool {
+ switch r {
+ case ToolDescriptorApprovalSourceAgent, ToolDescriptorApprovalSourceEnv, ToolDescriptorApprovalSourceCatalog:
+ return true
+ }
+ return false
+}
+
+type ToolDescriptorCategory string
+
+const (
+ ToolDescriptorCategoryBuiltIn ToolDescriptorCategory = "builtIn"
+ ToolDescriptorCategoryConfigurable ToolDescriptorCategory = "configurable"
+)
+
+func (r ToolDescriptorCategory) IsKnown() bool {
+ switch r {
+ case ToolDescriptorCategoryBuiltIn, ToolDescriptorCategoryConfigurable:
+ return true
+ }
+ return false
+}
+
type AgentDeleteResponse struct {
Success AgentDeleteResponseSuccess `json:"success" api:"required"`
JSON agentDeleteResponseJSON `json:"-"`
@@ -542,6 +904,32 @@ func (r AgentDeleteResponseSuccess) IsKnown() bool {
return false
}
+// Response for GET /agents/{agentId}/tools. The tools field is an inspection list,
+// not a configuration request field.
+type AgentListToolsResponse struct {
+ // Unified list of runtime and external tools currently available to the agent.
+ Tools []Tool `json:"tools" api:"required"`
+ SourceWarnings []SourceWarning `json:"sourceWarnings"`
+ JSON agentListToolsResponseJSON `json:"-"`
+}
+
+// agentListToolsResponseJSON contains the JSON metadata for the struct
+// [AgentListToolsResponse]
+type agentListToolsResponseJSON struct {
+ Tools apijson.Field
+ SourceWarnings apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *AgentListToolsResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r agentListToolsResponseJSON) RawJSON() string {
+ return r.raw
+}
+
type AgentNewParams struct {
Configuration param.Field[ConfigurationParam] `json:"configuration"`
FleetID param.Field[string] `json:"fleetId"`
diff --git a/agent_test.go b/agent_test.go
index e04228f..717242a 100644
--- a/agent_test.go
+++ b/agent_test.go
@@ -162,6 +162,28 @@ func TestAgentDelete(t *testing.T) {
}
}
+func TestAgentListTools(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Agents.ListTools(context.TODO(), "agent_abc123")
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
func TestAgentGetConfig(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
diff --git a/aliases.go b/aliases.go
index cd5c747..c0d9592 100644
--- a/aliases.go
+++ b/aliases.go
@@ -139,13 +139,15 @@ const ToolNameAgentScheduleDelete = shared.ToolNameAgentScheduleDelete
const ToolNameAgentScheduleTrigger = shared.ToolNameAgentScheduleTrigger
// Configurable runtime tool name, configurable namespace wildcard such as
-// sandbox._, or external namespace wildcard such as google._.
+// sandbox._, or external namespace wildcard such as google._. At thread and turn
+// scope, entries can only narrow the agent's effective tools.
//
// This is an alias to an internal type.
type ToolSpec = shared.ToolSpec
// Configurable runtime tool name, configurable namespace wildcard such as
-// sandbox._, or external namespace wildcard such as google._.
+// sandbox._, or external namespace wildcard such as google._. At thread and turn
+// scope, entries can only narrow the agent's effective tools.
//
// This is an alias to an internal type.
type ToolSpecParam = shared.ToolSpecParam
diff --git a/api.md b/api.md
index 0d190c0..649f888 100644
--- a/api.md
+++ b/api.md
@@ -34,20 +34,33 @@ Methods:
- client.OAuth.Connect(ctx context.Context, provider string, body cercago.OAuthConnectParams) (\*cercago.OAuthConnectResponse, error)
-# Credentials
+# Connections
+
+Params Types:
+
+- cercago.ConnectionOwnerUnionParam
+- cercago.ToolConnectionMetadataParam
Response Types:
+- cercago.AttachedConnection
- cercago.Connection
+- cercago.ConnectionOwner
- cercago.CredentialProvider
- cercago.CredentialType
-- cercago.CredentialDeleteResponse
+- cercago.ToolConnectionMetadata
+- cercago.ConnectionDeleteResponse
+- cercago.ConnectionDetachResponse
+- cercago.ConnectionListForAgentResponse
Methods:
-- client.Credentials.List(ctx context.Context, scope string, query cercago.CredentialListParams) (\*pagination.ConnectionsCursorPage[cercago.Connection], error)
-- client.Credentials.Delete(ctx context.Context, scope string, connectionID string) (\*cercago.CredentialDeleteResponse, error)
-- client.Credentials.NewAPIKey(ctx context.Context, scope string, body cercago.CredentialNewAPIKeyParams) (\*cercago.Connection, error)
+- client.Connections.New(ctx context.Context, body cercago.ConnectionNewParams) (\*cercago.Connection, error)
+- client.Connections.List(ctx context.Context, query cercago.ConnectionListParams) (\*pagination.ConnectionsCursorPage[cercago.Connection], error)
+- client.Connections.Delete(ctx context.Context, connectionID string, body cercago.ConnectionDeleteParams) (\*cercago.ConnectionDeleteResponse, error)
+- client.Connections.Attach(ctx context.Context, agentID string, body cercago.ConnectionAttachParams) (\*cercago.AttachedConnection, error)
+- client.Connections.Detach(ctx context.Context, agentID string, connectionID string) (\*cercago.ConnectionDetachResponse, error)
+- client.Connections.ListForAgent(ctx context.Context, agentID string) (\*cercago.ConnectionListForAgentResponse, error)
# Fleets
@@ -55,36 +68,42 @@ Response Types:
- cercago.Fleet
-# ToolSources
+# Tools
Params Types:
+- cercago.AuthInjectionUnionParam
+- cercago.HTTPEndpointParam
- cercago.HTTPToolDefinitionParam
- cercago.HTTPToolExecutionPolicyParam
- cercago.McpToolExecutionPolicyParam
+- cercago.OAuthExchangeConfigUnionParam
+- cercago.ResponseNormalizationHintParam
- cercago.ToolApprovalMode
-- cercago.ToolSourceAuthParam
+- cercago.ToolSourceAuthUnionParam
Response Types:
+- cercago.AuthInjection
+- cercago.HTTPEndpoint
- cercago.HTTPToolDefinition
- cercago.HTTPToolExecutionPolicy
- cercago.HTTPToolSource
- cercago.McpToolExecutionPolicy
- cercago.McpToolSource
+- cercago.OAuthExchangeConfig
+- cercago.ResponseNormalizationHint
- cercago.ToolApprovalMode
- cercago.ToolSource
- cercago.ToolSourceAuth
-- cercago.ToolSourceListForAgentResponse
Methods:
-- client.ToolSources.New(ctx context.Context, fleetID string, body cercago.ToolSourceNewParams) (\*cercago.ToolSource, error)
-- client.ToolSources.Get(ctx context.Context, fleetID string, sourceID string) (\*cercago.ToolSource, error)
-- client.ToolSources.Update(ctx context.Context, fleetID string, sourceID string, body cercago.ToolSourceUpdateParams) (\*cercago.ToolSource, error)
-- client.ToolSources.List(ctx context.Context, fleetID string, query cercago.ToolSourceListParams) (\*pagination.SourcesCursorPage[cercago.ToolSource], error)
-- client.ToolSources.Delete(ctx context.Context, fleetID string, sourceID string) error
-- client.ToolSources.ListForAgent(ctx context.Context, agentID string) (\*cercago.ToolSourceListForAgentResponse, error)
+- client.Tools.New(ctx context.Context, fleetID string, body cercago.ToolNewParams) (\*cercago.ToolSource, error)
+- client.Tools.Get(ctx context.Context, fleetID string, sourceID string) (\*cercago.ToolSource, error)
+- client.Tools.Update(ctx context.Context, fleetID string, sourceID string, body cercago.ToolUpdateParams) (\*cercago.ToolSource, error)
+- client.Tools.List(ctx context.Context, fleetID string, query cercago.ToolListParams) (\*pagination.SourcesCursorPage[cercago.ToolSource], error)
+- client.Tools.Delete(ctx context.Context, fleetID string, sourceID string) error
# Webhooks
@@ -114,7 +133,6 @@ Methods:
Response Types:
- cercago.RuntimeWebhookEvent
-- cercago.RuntimeWebhookEventType
- cercago.SubscriptionEvent
Methods:
@@ -141,10 +159,15 @@ Response Types:
- cercago.ApprovalPolicy
- cercago.Configuration
- cercago.ConfigurationFieldName
+- cercago.DiscoveredTool
- cercago.EffectiveConfiguration
- cercago.ExecutionPrincipal
- cercago.Metadata
+- cercago.SourceWarning
+- cercago.Tool
+- cercago.ToolDescriptor
- cercago.AgentDeleteResponse
+- cercago.AgentListToolsResponse
Methods:
@@ -153,6 +176,7 @@ Methods:
- client.Agents.Update(ctx context.Context, agentID string, body cercago.AgentUpdateParams) (\*cercago.Agent, error)
- client.Agents.List(ctx context.Context, query cercago.AgentListParams) (\*pagination.AgentsCursorPage[cercago.AgentSummary], error)
- client.Agents.Delete(ctx context.Context, agentID string) (\*cercago.AgentDeleteResponse, error)
+- client.Agents.ListTools(ctx context.Context, agentID string) (\*cercago.AgentListToolsResponse, error)
- client.Agents.GetConfig(ctx context.Context, agentID string) (\*cercago.EffectiveConfiguration, error)
- client.Agents.UpdateMetadata(ctx context.Context, agentID string, body cercago.AgentUpdateMetadataParams) (\*cercago.Agent, error)
@@ -166,11 +190,10 @@ Response Types:
- cercago.CompiledContext
- cercago.ContentBlock
-- cercago.ContextWindow
- cercago.Message
-- cercago.PendingSubThread
- cercago.Status
- cercago.SteerResult
+- cercago.SubThreadSummary
- cercago.Thread
- cercago.ThreadSummary
- cercago.TokenUsage
@@ -204,43 +227,24 @@ Methods:
- client.Context.Search(ctx context.Context, agentID string, query cercago.ContextSearchParams) (\*pagination.ResultsCursorPage[cercago.SearchResult], error)
- client.Context.Write(ctx context.Context, agentID string, body cercago.ContextWriteParams) (\*cercago.Entry, error)
-# Connections
-
-Params Types:
-
-- cercago.ToolConnectionMetadataParam
-
-Response Types:
-
-- cercago.AttachedConnection
-- cercago.ToolConnectionMetadata
-- cercago.ConnectionListResponse
-- cercago.ConnectionDetachResponse
-
-Methods:
-
-- client.Connections.List(ctx context.Context, agentID string) (\*cercago.ConnectionListResponse, error)
-- client.Connections.Attach(ctx context.Context, agentID string, body cercago.ConnectionAttachParams) (\*cercago.AttachedConnection, error)
-- client.Connections.Detach(ctx context.Context, agentID string, connectionID string) (\*cercago.ConnectionDetachResponse, error)
-
# Schedules
Response Types:
-- cercago.ScheduledThread
+- cercago.Schedule
- cercago.ScheduleListResponse
- cercago.ScheduleDeleteResponse
- cercago.ScheduleTriggerResponse
Methods:
-- client.Schedules.New(ctx context.Context, agentID string, body cercago.ScheduleNewParams) (\*cercago.ScheduledThread, error)
-- client.Schedules.Update(ctx context.Context, agentID string, scheduleID string, body cercago.ScheduleUpdateParams) (\*cercago.ScheduledThread, error)
+- client.Schedules.New(ctx context.Context, agentID string, body cercago.ScheduleNewParams) (\*cercago.Schedule, error)
+- client.Schedules.Update(ctx context.Context, agentID string, scheduleID string, body cercago.ScheduleUpdateParams) (\*cercago.Schedule, error)
- client.Schedules.List(ctx context.Context, agentID string) (\*cercago.ScheduleListResponse, error)
- client.Schedules.Delete(ctx context.Context, agentID string, scheduleID string) (\*cercago.ScheduleDeleteResponse, error)
- client.Schedules.Trigger(ctx context.Context, agentID string, scheduleID string) (\*cercago.ScheduleTriggerResponse, error)
-# Approvals
+# ApprovalRequests
Response Types:
@@ -248,8 +252,8 @@ Response Types:
Methods:
-- client.Approvals.List(ctx context.Context, agentID string, query cercago.ApprovalListParams) (\*pagination.ApprovalsCursorPage[cercago.ApprovalRequest], error)
-- client.Approvals.Resolve(ctx context.Context, agentID string, threadID string, approvalID string, body cercago.ApprovalResolveParams) (\*cercago.ApprovalRequest, error)
+- client.ApprovalRequests.List(ctx context.Context, agentID string, query cercago.ApprovalRequestListParams) (\*pagination.ApprovalRequestsCursorPage[cercago.ApprovalRequest], error)
+- client.ApprovalRequests.Resolve(ctx context.Context, agentID string, threadID string, approvalID string, body cercago.ApprovalRequestResolveParams) (\*cercago.ApprovalRequest, error)
# ApprovalGrants
@@ -266,17 +270,6 @@ Methods:
- client.ApprovalGrants.DeleteForThread(ctx context.Context, agentID string, threadID string, grantID string) (\*cercago.ApprovalGrantDeleteForThreadResponse, error)
- client.ApprovalGrants.ListForThread(ctx context.Context, agentID string, threadID string) (\*[]cercago.ApprovalGrant, error)
-# Logs
-
-Response Types:
-
-- cercago.ThreadLog
-
-Methods:
-
-- client.Logs.ListForAgent(ctx context.Context, agentID string, query cercago.LogListForAgentParams) (\*pagination.LogsCursorPage[cercago.ThreadLog], error)
-- client.Logs.ListForThread(ctx context.Context, agentID string, threadID string, query cercago.LogListForThreadParams) (\*pagination.LogsCursorPage[cercago.ThreadLog], error)
-
# Sandbox
Response Types:
@@ -291,19 +284,6 @@ Methods:
- client.Sandbox.Read(ctx context.Context, agentID string, body cercago.SandboxReadParams) (\*cercago.ReadResponse, error)
- client.Sandbox.Write(ctx context.Context, agentID string, body cercago.SandboxWriteParams) (\*cercago.SandboxWriteResponse, error)
-# Tools
-
-Response Types:
-
-- cercago.RuntimeDiscoveredTool
-- cercago.RuntimeSourceWarning
-- cercago.RuntimeToolDescriptor
-- cercago.ToolListForAgentResponse
-
-Methods:
-
-- client.Tools.ListForAgent(ctx context.Context, agentID string) (\*cercago.ToolListForAgentResponse, error)
-
# Models
Response Types:
diff --git a/approvalgrant.go b/approvalgrant.go
index 0f3d8ea..679c9fa 100644
--- a/approvalgrant.go
+++ b/approvalgrant.go
@@ -37,6 +37,7 @@ func NewApprovalGrantService(opts ...option.RequestOption) (r *ApprovalGrantServ
return
}
+// Approval Grants
func (r *ApprovalGrantService) List(ctx context.Context, agentID string, query ApprovalGrantListParams, opts ...option.RequestOption) (res *pagination.GrantsCursorPage[ApprovalGrant], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -58,10 +59,12 @@ func (r *ApprovalGrantService) List(ctx context.Context, agentID string, query A
return res, nil
}
+// Approval Grants
func (r *ApprovalGrantService) ListAutoPaging(ctx context.Context, agentID string, query ApprovalGrantListParams, opts ...option.RequestOption) *pagination.GrantsCursorPageAutoPager[ApprovalGrant] {
return pagination.NewGrantsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
}
+// Approval Grant
func (r *ApprovalGrantService) Delete(ctx context.Context, agentID string, grantID string, opts ...option.RequestOption) (res *ApprovalGrantDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -77,6 +80,7 @@ func (r *ApprovalGrantService) Delete(ctx context.Context, agentID string, grant
return res, err
}
+// Approval Grant
func (r *ApprovalGrantService) DeleteForThread(ctx context.Context, agentID string, threadID string, grantID string, opts ...option.RequestOption) (res *ApprovalGrantDeleteForThreadResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -96,6 +100,7 @@ func (r *ApprovalGrantService) DeleteForThread(ctx context.Context, agentID stri
return res, err
}
+// Approval Grants
func (r *ApprovalGrantService) ListForThread(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (res *[]ApprovalGrant, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/approval.go b/approvalrequest.go
similarity index 60%
rename from approval.go
rename to approvalrequest.go
index e67a4a3..4706cc1 100644
--- a/approval.go
+++ b/approvalrequest.go
@@ -19,26 +19,27 @@ import (
"github.com/matrices/cerca-go/shared"
)
-// ApprovalService contains methods and other services that help with interacting
-// with the cerca API.
+// ApprovalRequestService contains methods and other services that help with
+// interacting with the cerca API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
-// the [NewApprovalService] method instead.
-type ApprovalService struct {
+// the [NewApprovalRequestService] method instead.
+type ApprovalRequestService struct {
Options []option.RequestOption
}
-// NewApprovalService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
+// NewApprovalRequestService generates a new service that applies the given options
+// to each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
-func NewApprovalService(opts ...option.RequestOption) (r *ApprovalService) {
- r = &ApprovalService{}
+func NewApprovalRequestService(opts ...option.RequestOption) (r *ApprovalRequestService) {
+ r = &ApprovalRequestService{}
r.Options = opts
return
}
-func (r *ApprovalService) List(ctx context.Context, agentID string, query ApprovalListParams, opts ...option.RequestOption) (res *pagination.ApprovalsCursorPage[ApprovalRequest], err error) {
+// Approvals
+func (r *ApprovalRequestService) List(ctx context.Context, agentID string, query ApprovalRequestListParams, opts ...option.RequestOption) (res *pagination.ApprovalRequestsCursorPage[ApprovalRequest], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
@@ -59,11 +60,13 @@ func (r *ApprovalService) List(ctx context.Context, agentID string, query Approv
return res, nil
}
-func (r *ApprovalService) ListAutoPaging(ctx context.Context, agentID string, query ApprovalListParams, opts ...option.RequestOption) *pagination.ApprovalsCursorPageAutoPager[ApprovalRequest] {
- return pagination.NewApprovalsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
+// Approvals
+func (r *ApprovalRequestService) ListAutoPaging(ctx context.Context, agentID string, query ApprovalRequestListParams, opts ...option.RequestOption) *pagination.ApprovalRequestsCursorPageAutoPager[ApprovalRequest] {
+ return pagination.NewApprovalRequestsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
}
-func (r *ApprovalService) Resolve(ctx context.Context, agentID string, threadID string, approvalID string, body ApprovalResolveParams, opts ...option.RequestOption) (res *ApprovalRequest, err error) {
+// Approval
+func (r *ApprovalRequestService) Resolve(ctx context.Context, agentID string, threadID string, approvalID string, body ApprovalRequestResolveParams, opts ...option.RequestOption) (res *ApprovalRequest, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
err = errors.New("missing required agentId parameter")
@@ -83,17 +86,19 @@ func (r *ApprovalService) Resolve(ctx context.Context, agentID string, threadID
}
type ApprovalRequest struct {
- ID string `json:"id" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- RequestedToolName string `json:"requestedToolName" api:"required"`
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ // Parsed JSON tool input from the original tool call. Generated SDKs may expose
+ // this as unknown or Any.
+ Input interface{} `json:"input" api:"required"`
ResolvedAt string `json:"resolvedAt" api:"required,nullable"`
+ RuntimeToolName shared.ToolName `json:"runtimeToolName" api:"required"`
Status ApprovalRequestStatus `json:"status" api:"required"`
ThreadID string `json:"threadId" api:"required"`
TimeoutAt string `json:"timeoutAt" api:"required,nullable"`
TimeoutMs float64 `json:"timeoutMs" api:"required,nullable"`
ToolIndex float64 `json:"toolIndex" api:"required"`
- ToolInput string `json:"toolInput" api:"required"`
- ToolName shared.ToolName `json:"toolName" api:"required"`
+ ToolName string `json:"toolName" api:"required"`
ToolUseID string `json:"toolUseId" api:"required"`
TurnID string `json:"turnId" api:"required"`
ToolSourceID string `json:"toolSourceId"`
@@ -105,14 +110,14 @@ type ApprovalRequest struct {
type approvalRequestJSON struct {
ID apijson.Field
CreatedAt apijson.Field
- RequestedToolName apijson.Field
+ Input apijson.Field
ResolvedAt apijson.Field
+ RuntimeToolName apijson.Field
Status apijson.Field
ThreadID apijson.Field
TimeoutAt apijson.Field
TimeoutMs apijson.Field
ToolIndex apijson.Field
- ToolInput apijson.Field
ToolName apijson.Field
ToolUseID apijson.Field
TurnID apijson.Field
@@ -148,7 +153,7 @@ func (r ApprovalRequestStatus) IsKnown() bool {
return false
}
-type ApprovalListParams struct {
+type ApprovalRequestListParams struct {
// Opaque pagination cursor returned by a previous request.
Cursor param.Field[string] `query:"cursor"`
// Maximum number of items to return. Defaults to 20 and preserves parseInt
@@ -158,49 +163,50 @@ type ApprovalListParams struct {
ThreadID param.Field[string] `query:"threadId"`
}
-// URLQuery serializes [ApprovalListParams]'s query parameters as `url.Values`.
-func (r ApprovalListParams) URLQuery() (v url.Values) {
+// URLQuery serializes [ApprovalRequestListParams]'s query parameters as
+// `url.Values`.
+func (r ApprovalRequestListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
-type ApprovalResolveParams struct {
- Decision param.Field[ApprovalResolveParamsDecision] `json:"decision" api:"required"`
- Grant param.Field[ApprovalResolveParamsGrant] `json:"grant"`
+type ApprovalRequestResolveParams struct {
+ Decision param.Field[ApprovalRequestResolveParamsDecision] `json:"decision" api:"required"`
+ Grant param.Field[ApprovalRequestResolveParamsGrant] `json:"grant"`
}
-func (r ApprovalResolveParams) MarshalJSON() (data []byte, err error) {
+func (r ApprovalRequestResolveParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-type ApprovalResolveParamsDecision string
+type ApprovalRequestResolveParamsDecision string
const (
- ApprovalResolveParamsDecisionApprove ApprovalResolveParamsDecision = "approve"
- ApprovalResolveParamsDecisionDeny ApprovalResolveParamsDecision = "deny"
- ApprovalResolveParamsDecisionCancel ApprovalResolveParamsDecision = "cancel"
+ ApprovalRequestResolveParamsDecisionApprove ApprovalRequestResolveParamsDecision = "approve"
+ ApprovalRequestResolveParamsDecisionDeny ApprovalRequestResolveParamsDecision = "deny"
+ ApprovalRequestResolveParamsDecisionCancel ApprovalRequestResolveParamsDecision = "cancel"
)
-func (r ApprovalResolveParamsDecision) IsKnown() bool {
+func (r ApprovalRequestResolveParamsDecision) IsKnown() bool {
switch r {
- case ApprovalResolveParamsDecisionApprove, ApprovalResolveParamsDecisionDeny, ApprovalResolveParamsDecisionCancel:
+ case ApprovalRequestResolveParamsDecisionApprove, ApprovalRequestResolveParamsDecisionDeny, ApprovalRequestResolveParamsDecisionCancel:
return true
}
return false
}
-type ApprovalResolveParamsGrant string
+type ApprovalRequestResolveParamsGrant string
const (
- ApprovalResolveParamsGrantThread ApprovalResolveParamsGrant = "thread"
- ApprovalResolveParamsGrantAgent ApprovalResolveParamsGrant = "agent"
+ ApprovalRequestResolveParamsGrantThread ApprovalRequestResolveParamsGrant = "thread"
+ ApprovalRequestResolveParamsGrantAgent ApprovalRequestResolveParamsGrant = "agent"
)
-func (r ApprovalResolveParamsGrant) IsKnown() bool {
+func (r ApprovalRequestResolveParamsGrant) IsKnown() bool {
switch r {
- case ApprovalResolveParamsGrantThread, ApprovalResolveParamsGrantAgent:
+ case ApprovalRequestResolveParamsGrantThread, ApprovalRequestResolveParamsGrantAgent:
return true
}
return false
diff --git a/approval_test.go b/approvalrequest_test.go
similarity index 76%
rename from approval_test.go
rename to approvalrequest_test.go
index ba1162f..167a48a 100644
--- a/approval_test.go
+++ b/approvalrequest_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestApprovalListWithOptionalParams(t *testing.T) {
+func TestApprovalRequestListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,10 +25,10 @@ func TestApprovalListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Approvals.List(
+ _, err := client.ApprovalRequests.List(
context.TODO(),
"agent_abc123",
- cercago.ApprovalListParams{
+ cercago.ApprovalRequestListParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
ThreadID: cercago.F("thread_abc123"),
@@ -43,7 +43,7 @@ func TestApprovalListWithOptionalParams(t *testing.T) {
}
}
-func TestApprovalResolveWithOptionalParams(t *testing.T) {
+func TestApprovalRequestResolveWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -55,14 +55,14 @@ func TestApprovalResolveWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Approvals.Resolve(
+ _, err := client.ApprovalRequests.Resolve(
context.TODO(),
"agent_abc123",
"thread_abc123",
"approval_abc123",
- cercago.ApprovalResolveParams{
- Decision: cercago.F(cercago.ApprovalResolveParamsDecisionApprove),
- Grant: cercago.F(cercago.ApprovalResolveParamsGrantThread),
+ cercago.ApprovalRequestResolveParams{
+ Decision: cercago.F(cercago.ApprovalRequestResolveParamsDecisionApprove),
+ Grant: cercago.F(cercago.ApprovalRequestResolveParamsGrantThread),
},
)
if err != nil {
diff --git a/auth.go b/auth.go
index 79e6322..d2c081a 100644
--- a/auth.go
+++ b/auth.go
@@ -35,6 +35,7 @@ func NewAuthService(opts ...option.RequestOption) (r *AuthService) {
return
}
+// Context
func (r *AuthService) Context(ctx context.Context, opts ...option.RequestOption) (res *AuthContextResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "auth/context"
@@ -42,6 +43,7 @@ func (r *AuthService) Context(ctx context.Context, opts ...option.RequestOption)
return res, err
}
+// Fleets
func (r *AuthService) ListFleets(ctx context.Context, query AuthListFleetsParams, opts ...option.RequestOption) (res *pagination.FleetsCursorPage[Fleet], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -59,6 +61,7 @@ func (r *AuthService) ListFleets(ctx context.Context, query AuthListFleetsParams
return res, nil
}
+// Fleets
func (r *AuthService) ListFleetsAutoPaging(ctx context.Context, query AuthListFleetsParams, opts ...option.RequestOption) *pagination.FleetsCursorPageAutoPager[Fleet] {
return pagination.NewFleetsCursorPageAutoPager(r.ListFleets(ctx, query, opts...))
}
diff --git a/client.go b/client.go
index 602dc44..a6a714d 100644
--- a/client.go
+++ b/client.go
@@ -17,25 +17,22 @@ import (
// interacting with the cerca API. You should not instantiate this client directly,
// and instead use the [NewClient] method instead.
type Client struct {
- Options []option.RequestOption
- Auth *AuthService
- OAuth *OAuthService
- Credentials *CredentialService
- Fleets *FleetService
- ToolSources *ToolSourceService
- Webhooks *WebhookService
- Events *EventService
- Agents *AgentService
- Threads *ThreadService
- Context *ContextService
- Connections *ConnectionService
- Schedules *ScheduleService
- Approvals *ApprovalService
- ApprovalGrants *ApprovalGrantService
- Logs *LogService
- Sandbox *SandboxService
- Tools *ToolService
- Models *ModelService
+ Options []option.RequestOption
+ Auth *AuthService
+ OAuth *OAuthService
+ Connections *ConnectionService
+ Fleets *FleetService
+ Tools *ToolService
+ Webhooks *WebhookService
+ Events *EventService
+ Agents *AgentService
+ Threads *ThreadService
+ Context *ContextService
+ Schedules *ScheduleService
+ ApprovalRequests *ApprovalRequestService
+ ApprovalGrants *ApprovalGrantService
+ Sandbox *SandboxService
+ Models *ModelService
}
// DefaultClientOptions read from the environment (CERCA_API_KEY, CERCA_BASE_URL).
@@ -70,21 +67,18 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
r.Auth = NewAuthService(opts...)
r.OAuth = NewOAuthService(opts...)
- r.Credentials = NewCredentialService(opts...)
+ r.Connections = NewConnectionService(opts...)
r.Fleets = NewFleetService(opts...)
- r.ToolSources = NewToolSourceService(opts...)
+ r.Tools = NewToolService(opts...)
r.Webhooks = NewWebhookService(opts...)
r.Events = NewEventService(opts...)
r.Agents = NewAgentService(opts...)
r.Threads = NewThreadService(opts...)
r.Context = NewContextService(opts...)
- r.Connections = NewConnectionService(opts...)
r.Schedules = NewScheduleService(opts...)
- r.Approvals = NewApprovalService(opts...)
+ r.ApprovalRequests = NewApprovalRequestService(opts...)
r.ApprovalGrants = NewApprovalGrantService(opts...)
- r.Logs = NewLogService(opts...)
r.Sandbox = NewSandboxService(opts...)
- r.Tools = NewToolService(opts...)
r.Models = NewModelService(opts...)
return
diff --git a/connection.go b/connection.go
index 1edd7f7..1d39d1f 100644
--- a/connection.go
+++ b/connection.go
@@ -7,12 +7,17 @@ import (
"errors"
"fmt"
"net/http"
+ "net/url"
+ "reflect"
"slices"
"github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
"github.com/matrices/cerca-go/internal/param"
"github.com/matrices/cerca-go/internal/requestconfig"
"github.com/matrices/cerca-go/option"
+ "github.com/matrices/cerca-go/packages/pagination"
+ "github.com/tidwall/gjson"
)
// ConnectionService contains methods and other services that help with interacting
@@ -34,17 +39,50 @@ func NewConnectionService(opts ...option.RequestOption) (r *ConnectionService) {
return
}
-func (r *ConnectionService) List(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ConnectionListResponse, err error) {
+// API Keys
+func (r *ConnectionService) New(ctx context.Context, body ConnectionNewParams, opts ...option.RequestOption) (res *Connection, err error) {
opts = slices.Concat(r.Options, opts)
- if agentID == "" {
- err = errors.New("missing required agentId parameter")
+ path := "connections/api-keys"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// Connections
+func (r *ConnectionService) List(ctx context.Context, query ConnectionListParams, opts ...option.RequestOption) (res *pagination.ConnectionsCursorPage[Connection], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ path := "connections"
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
return nil, err
}
- path := fmt.Sprintf("agents/%s/connections", agentID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+// Connections
+func (r *ConnectionService) ListAutoPaging(ctx context.Context, query ConnectionListParams, opts ...option.RequestOption) *pagination.ConnectionsCursorPageAutoPager[Connection] {
+ return pagination.NewConnectionsCursorPageAutoPager(r.List(ctx, query, opts...))
+}
+
+// Connection
+func (r *ConnectionService) Delete(ctx context.Context, connectionID string, body ConnectionDeleteParams, opts ...option.RequestOption) (res *ConnectionDeleteResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if connectionID == "" {
+ err = errors.New("missing required connectionId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("connections/%s", connectionID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...)
return res, err
}
+// Connections
func (r *ConnectionService) Attach(ctx context.Context, agentID string, body ConnectionAttachParams, opts ...option.RequestOption) (res *AttachedConnection, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -56,6 +94,7 @@ func (r *ConnectionService) Attach(ctx context.Context, agentID string, body Con
return res, err
}
+// Connection
func (r *ConnectionService) Detach(ctx context.Context, agentID string, connectionID string, opts ...option.RequestOption) (res *ConnectionDetachResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -71,6 +110,18 @@ func (r *ConnectionService) Detach(ctx context.Context, agentID string, connecti
return res, err
}
+// Connections
+func (r *ConnectionService) ListForAgent(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ConnectionListForAgentResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("agents/%s/connections", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
type AttachedConnection struct {
AttachedAt string `json:"attachedAt" api:"required"`
Metadata ToolConnectionMetadata `json:"metadata"`
@@ -95,35 +146,316 @@ func (r attachedConnectionJSON) RawJSON() string {
return r.raw
}
+type Connection struct {
+ ID string `json:"id" api:"required" format:"uuid"`
+ AccountLabel string `json:"accountLabel" api:"required,nullable"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ // Public owner for a reusable connection. Organization owners use the
+ // authenticated organization; fleet owners add a fleetId.
+ Owner ConnectionOwner `json:"owner" api:"required"`
+ Provider CredentialProvider `json:"provider" api:"required"`
+ Scopes []string `json:"scopes" api:"required"`
+ Type CredentialType `json:"type" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ JSON connectionJSON `json:"-"`
+}
+
+// connectionJSON contains the JSON metadata for the struct [Connection]
+type connectionJSON struct {
+ ID apijson.Field
+ AccountLabel apijson.Field
+ CreatedAt apijson.Field
+ Owner apijson.Field
+ Provider apijson.Field
+ Scopes apijson.Field
+ Type apijson.Field
+ UpdatedAt apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Connection) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r connectionJSON) RawJSON() string {
+ return r.raw
+}
+
+// Public owner for a reusable connection. Organization owners use the
+// authenticated organization; fleet owners add a fleetId.
+type ConnectionOwner struct {
+ Type ConnectionOwnerType `json:"type" api:"required"`
+ FleetID string `json:"fleetId"`
+ JSON connectionOwnerJSON `json:"-"`
+ union ConnectionOwnerUnion
+}
+
+// connectionOwnerJSON contains the JSON metadata for the struct [ConnectionOwner]
+type connectionOwnerJSON struct {
+ Type apijson.Field
+ FleetID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r connectionOwnerJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *ConnectionOwner) UnmarshalJSON(data []byte) (err error) {
+ *r = ConnectionOwner{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [ConnectionOwnerUnion] interface which you can cast to the
+// specific types for more type safety.
+//
+// Possible runtime types of the union are
+// [ConnectionOwnerOrganizationConnectionOwner],
+// [ConnectionOwnerFleetConnectionOwner].
+func (r ConnectionOwner) AsUnion() ConnectionOwnerUnion {
+ return r.union
+}
+
+// Public owner for a reusable connection. Organization owners use the
+// authenticated organization; fleet owners add a fleetId.
+//
+// Union satisfied by [ConnectionOwnerOrganizationConnectionOwner] or
+// [ConnectionOwnerFleetConnectionOwner].
+type ConnectionOwnerUnion interface {
+ implementsConnectionOwner()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ConnectionOwnerUnion)(nil)).Elem(),
+ "type",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ConnectionOwnerOrganizationConnectionOwner{}),
+ DiscriminatorValue: "organization",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ConnectionOwnerFleetConnectionOwner{}),
+ DiscriminatorValue: "fleet",
+ },
+ )
+}
+
+type ConnectionOwnerOrganizationConnectionOwner struct {
+ Type ConnectionOwnerOrganizationConnectionOwnerType `json:"type" api:"required"`
+ JSON connectionOwnerOrganizationConnectionOwnerJSON `json:"-"`
+}
+
+// connectionOwnerOrganizationConnectionOwnerJSON contains the JSON metadata for
+// the struct [ConnectionOwnerOrganizationConnectionOwner]
+type connectionOwnerOrganizationConnectionOwnerJSON struct {
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConnectionOwnerOrganizationConnectionOwner) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r connectionOwnerOrganizationConnectionOwnerJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ConnectionOwnerOrganizationConnectionOwner) implementsConnectionOwner() {}
+
+type ConnectionOwnerOrganizationConnectionOwnerType string
+
+const (
+ ConnectionOwnerOrganizationConnectionOwnerTypeOrganization ConnectionOwnerOrganizationConnectionOwnerType = "organization"
+)
+
+func (r ConnectionOwnerOrganizationConnectionOwnerType) IsKnown() bool {
+ switch r {
+ case ConnectionOwnerOrganizationConnectionOwnerTypeOrganization:
+ return true
+ }
+ return false
+}
+
+type ConnectionOwnerFleetConnectionOwner struct {
+ FleetID string `json:"fleetId" api:"required"`
+ Type ConnectionOwnerFleetConnectionOwnerType `json:"type" api:"required"`
+ JSON connectionOwnerFleetConnectionOwnerJSON `json:"-"`
+}
+
+// connectionOwnerFleetConnectionOwnerJSON contains the JSON metadata for the
+// struct [ConnectionOwnerFleetConnectionOwner]
+type connectionOwnerFleetConnectionOwnerJSON struct {
+ FleetID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConnectionOwnerFleetConnectionOwner) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r connectionOwnerFleetConnectionOwnerJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ConnectionOwnerFleetConnectionOwner) implementsConnectionOwner() {}
+
+type ConnectionOwnerFleetConnectionOwnerType string
+
+const (
+ ConnectionOwnerFleetConnectionOwnerTypeFleet ConnectionOwnerFleetConnectionOwnerType = "fleet"
+)
+
+func (r ConnectionOwnerFleetConnectionOwnerType) IsKnown() bool {
+ switch r {
+ case ConnectionOwnerFleetConnectionOwnerTypeFleet:
+ return true
+ }
+ return false
+}
+
+type ConnectionOwnerType string
+
+const (
+ ConnectionOwnerTypeOrganization ConnectionOwnerType = "organization"
+ ConnectionOwnerTypeFleet ConnectionOwnerType = "fleet"
+)
+
+func (r ConnectionOwnerType) IsKnown() bool {
+ switch r {
+ case ConnectionOwnerTypeOrganization, ConnectionOwnerTypeFleet:
+ return true
+ }
+ return false
+}
+
+// Public owner for a reusable connection. Organization owners use the
+// authenticated organization; fleet owners add a fleetId.
+type ConnectionOwnerParam struct {
+ Type param.Field[ConnectionOwnerType] `json:"type" api:"required"`
+ FleetID param.Field[string] `json:"fleetId"`
+}
+
+func (r ConnectionOwnerParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ConnectionOwnerParam) implementsConnectionOwnerUnionParam() {}
+
+// Public owner for a reusable connection. Organization owners use the
+// authenticated organization; fleet owners add a fleetId.
+//
+// Satisfied by [ConnectionOwnerOrganizationConnectionOwnerParam],
+// [ConnectionOwnerFleetConnectionOwnerParam], [ConnectionOwnerParam].
+type ConnectionOwnerUnionParam interface {
+ implementsConnectionOwnerUnionParam()
+}
+
+type ConnectionOwnerOrganizationConnectionOwnerParam struct {
+ Type param.Field[ConnectionOwnerOrganizationConnectionOwnerType] `json:"type" api:"required"`
+}
+
+func (r ConnectionOwnerOrganizationConnectionOwnerParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ConnectionOwnerOrganizationConnectionOwnerParam) implementsConnectionOwnerUnionParam() {}
+
+type ConnectionOwnerFleetConnectionOwnerParam struct {
+ FleetID param.Field[string] `json:"fleetId" api:"required"`
+ Type param.Field[ConnectionOwnerFleetConnectionOwnerType] `json:"type" api:"required"`
+}
+
+func (r ConnectionOwnerFleetConnectionOwnerParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ConnectionOwnerFleetConnectionOwnerParam) implementsConnectionOwnerUnionParam() {}
+
+type CredentialProvider string
+
+const (
+ CredentialProviderGoogle CredentialProvider = "google"
+ CredentialProviderGitHub CredentialProvider = "github"
+ CredentialProviderSlack CredentialProvider = "slack"
+ CredentialProviderLinear CredentialProvider = "linear"
+ CredentialProviderNotion CredentialProvider = "notion"
+ CredentialProviderCustom CredentialProvider = "custom"
+ CredentialProviderWebhook CredentialProvider = "webhook"
+)
+
+func (r CredentialProvider) IsKnown() bool {
+ switch r {
+ case CredentialProviderGoogle, CredentialProviderGitHub, CredentialProviderSlack, CredentialProviderLinear, CredentialProviderNotion, CredentialProviderCustom, CredentialProviderWebhook:
+ return true
+ }
+ return false
+}
+
+type CredentialType string
+
+const (
+ CredentialTypeOAuth CredentialType = "oauth"
+ CredentialTypeAPIKey CredentialType = "api_key"
+)
+
+func (r CredentialType) IsKnown() bool {
+ switch r {
+ case CredentialTypeOAuth, CredentialTypeAPIKey:
+ return true
+ }
+ return false
+}
+
type ToolConnectionMetadata map[string]string
type ToolConnectionMetadataParam map[string]string
-type ConnectionListResponse struct {
- Connections []AttachedConnection `json:"connections" api:"required"`
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- JSON connectionListResponseJSON `json:"-"`
+type ConnectionDeleteResponse struct {
+ Success ConnectionDeleteResponseSuccess `json:"success" api:"required"`
+ JSON connectionDeleteResponseJSON `json:"-"`
}
-// connectionListResponseJSON contains the JSON metadata for the struct
-// [ConnectionListResponse]
-type connectionListResponseJSON struct {
- Connections apijson.Field
- Cursor apijson.Field
- HasMore apijson.Field
+// connectionDeleteResponseJSON contains the JSON metadata for the struct
+// [ConnectionDeleteResponse]
+type connectionDeleteResponseJSON struct {
+ Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *ConnectionListResponse) UnmarshalJSON(data []byte) (err error) {
+func (r *ConnectionDeleteResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r connectionListResponseJSON) RawJSON() string {
+func (r connectionDeleteResponseJSON) RawJSON() string {
return r.raw
}
+type ConnectionDeleteResponseSuccess bool
+
+const (
+ ConnectionDeleteResponseSuccessTrue ConnectionDeleteResponseSuccess = true
+)
+
+func (r ConnectionDeleteResponseSuccess) IsKnown() bool {
+ switch r {
+ case ConnectionDeleteResponseSuccessTrue:
+ return true
+ }
+ return false
+}
+
type ConnectionDetachResponse struct {
Success ConnectionDetachResponseSuccess `json:"success" api:"required"`
JSON connectionDetachResponseJSON `json:"-"`
@@ -159,8 +491,116 @@ func (r ConnectionDetachResponseSuccess) IsKnown() bool {
return false
}
+type ConnectionListForAgentResponse struct {
+ Connections []AttachedConnection `json:"connections" api:"required"`
+ Cursor string `json:"cursor" api:"required,nullable"`
+ HasMore bool `json:"hasMore" api:"required"`
+ JSON connectionListForAgentResponseJSON `json:"-"`
+}
+
+// connectionListForAgentResponseJSON contains the JSON metadata for the struct
+// [ConnectionListForAgentResponse]
+type connectionListForAgentResponseJSON struct {
+ Connections apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConnectionListForAgentResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r connectionListForAgentResponseJSON) RawJSON() string {
+ return r.raw
+}
+
+type ConnectionNewParams struct {
+ // API key secret. It is stored securely and is not returned.
+ APIKey param.Field[string] `json:"apiKey" api:"required"`
+ // Public owner for a reusable connection. Organization owners use the
+ // authenticated organization; fleet owners add a fleetId.
+ Owner param.Field[ConnectionOwnerUnionParam] `json:"owner" api:"required"`
+ // Credential provider to store an API key for.
+ Provider param.Field[string] `json:"provider" api:"required"`
+ // Optional human-readable account label.
+ AccountLabel param.Field[string] `json:"accountLabel"`
+}
+
+func (r ConnectionNewParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type ConnectionListParams struct {
+ // Public connection owner type.
+ OwnerType param.Field[ConnectionListParamsOwnerType] `query:"ownerType" api:"required"`
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Required when ownerType is fleet.
+ FleetID param.Field[string] `query:"fleetId"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [ConnectionListParams]'s query parameters as `url.Values`.
+func (r ConnectionListParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// Public connection owner type.
+type ConnectionListParamsOwnerType string
+
+const (
+ ConnectionListParamsOwnerTypeOrganization ConnectionListParamsOwnerType = "organization"
+ ConnectionListParamsOwnerTypeFleet ConnectionListParamsOwnerType = "fleet"
+)
+
+func (r ConnectionListParamsOwnerType) IsKnown() bool {
+ switch r {
+ case ConnectionListParamsOwnerTypeOrganization, ConnectionListParamsOwnerTypeFleet:
+ return true
+ }
+ return false
+}
+
+type ConnectionDeleteParams struct {
+ // Public connection owner type.
+ OwnerType param.Field[ConnectionDeleteParamsOwnerType] `query:"ownerType" api:"required"`
+ // Required when ownerType is fleet.
+ FleetID param.Field[string] `query:"fleetId"`
+}
+
+// URLQuery serializes [ConnectionDeleteParams]'s query parameters as `url.Values`.
+func (r ConnectionDeleteParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// Public connection owner type.
+type ConnectionDeleteParamsOwnerType string
+
+const (
+ ConnectionDeleteParamsOwnerTypeOrganization ConnectionDeleteParamsOwnerType = "organization"
+ ConnectionDeleteParamsOwnerTypeFleet ConnectionDeleteParamsOwnerType = "fleet"
+)
+
+func (r ConnectionDeleteParamsOwnerType) IsKnown() bool {
+ switch r {
+ case ConnectionDeleteParamsOwnerTypeOrganization, ConnectionDeleteParamsOwnerTypeFleet:
+ return true
+ }
+ return false
+}
+
type ConnectionAttachParams struct {
- ConnectionID param.Field[string] `json:"connectionId" api:"required"`
+ ConnectionID param.Field[string] `json:"connectionId" api:"required" format:"uuid"`
Metadata param.Field[ToolConnectionMetadataParam] `json:"metadata"`
}
diff --git a/connection_test.go b/connection_test.go
index 4396e86..b711699 100644
--- a/connection_test.go
+++ b/connection_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestConnectionList(t *testing.T) {
+func TestConnectionNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,7 +25,70 @@ func TestConnectionList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Connections.List(context.TODO(), "agent_abc123")
+ _, err := client.Connections.New(context.TODO(), cercago.ConnectionNewParams{
+ APIKey: cercago.F("sk_live_..."),
+ Owner: cercago.F[cercago.ConnectionOwnerUnionParam](cercago.ConnectionOwnerOrganizationConnectionOwnerParam{
+ Type: cercago.F(cercago.ConnectionOwnerOrganizationConnectionOwnerTypeOrganization),
+ }),
+ Provider: cercago.F("custom"),
+ AccountLabel: cercago.F("primary"),
+ })
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestConnectionListWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Connections.List(context.TODO(), cercago.ConnectionListParams{
+ OwnerType: cercago.F(cercago.ConnectionListParamsOwnerTypeFleet),
+ Cursor: cercago.F("cursor_abc123"),
+ FleetID: cercago.F("fleet_abc123"),
+ Limit: cercago.F("20"),
+ })
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestConnectionDeleteWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Connections.Delete(
+ context.TODO(),
+ "9f063c59-2775-4614-8a68-22e5f90f92f3",
+ cercago.ConnectionDeleteParams{
+ OwnerType: cercago.F(cercago.ConnectionDeleteParamsOwnerTypeFleet),
+ FleetID: cercago.F("fleet_abc123"),
+ },
+ )
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
@@ -51,7 +114,7 @@ func TestConnectionAttachWithOptionalParams(t *testing.T) {
context.TODO(),
"agent_abc123",
cercago.ConnectionAttachParams{
- ConnectionID: cercago.F("connectionId"),
+ ConnectionID: cercago.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
Metadata: cercago.F(cercago.ToolConnectionMetadataParam{
"foo": "string",
}),
@@ -81,8 +144,30 @@ func TestConnectionDetach(t *testing.T) {
_, err := client.Connections.Detach(
context.TODO(),
"agent_abc123",
- "env:org_abc123:fleet_abc123::conn_abc123",
+ "9f063c59-2775-4614-8a68-22e5f90f92f3",
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestConnectionListForAgent(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
)
+ _, err := client.Connections.ListForAgent(context.TODO(), "agent_abc123")
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
diff --git a/context.go b/context.go
index dc34a89..c8b2d6d 100644
--- a/context.go
+++ b/context.go
@@ -37,6 +37,7 @@ func NewContextService(opts ...option.RequestOption) (r *ContextService) {
return
}
+// Entry
func (r *ContextService) Get(ctx context.Context, agentID string, query ContextGetParams, opts ...option.RequestOption) (res *Entry, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -48,6 +49,7 @@ func (r *ContextService) Get(ctx context.Context, agentID string, query ContextG
return res, err
}
+// Context
func (r *ContextService) List(ctx context.Context, agentID string, query ContextListParams, opts ...option.RequestOption) (res *pagination.EntriesCursorPage[EntrySummary], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -69,10 +71,12 @@ func (r *ContextService) List(ctx context.Context, agentID string, query Context
return res, nil
}
+// Context
func (r *ContextService) ListAutoPaging(ctx context.Context, agentID string, query ContextListParams, opts ...option.RequestOption) *pagination.EntriesCursorPageAutoPager[EntrySummary] {
return pagination.NewEntriesCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
}
+// Entry
func (r *ContextService) Delete(ctx context.Context, agentID string, body ContextDeleteParams, opts ...option.RequestOption) (res *ContextDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -84,6 +88,7 @@ func (r *ContextService) Delete(ctx context.Context, agentID string, body Contex
return res, err
}
+// Search
func (r *ContextService) Search(ctx context.Context, agentID string, query ContextSearchParams, opts ...option.RequestOption) (res *pagination.ResultsCursorPage[SearchResult], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -105,10 +110,12 @@ func (r *ContextService) Search(ctx context.Context, agentID string, query Conte
return res, nil
}
+// Search
func (r *ContextService) SearchAutoPaging(ctx context.Context, agentID string, query ContextSearchParams, opts ...option.RequestOption) *pagination.ResultsCursorPageAutoPager[SearchResult] {
return pagination.NewResultsCursorPageAutoPager(r.Search(ctx, agentID, query, opts...))
}
+// Entry
func (r *ContextService) Write(ctx context.Context, agentID string, body ContextWriteParams, opts ...option.RequestOption) (res *Entry, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/credential.go b/credential.go
deleted file mode 100644
index a4e7aab..0000000
--- a/credential.go
+++ /dev/null
@@ -1,223 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
- "github.com/matrices/cerca-go/packages/pagination"
-)
-
-// CredentialService contains methods and other services that help with interacting
-// with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewCredentialService] method instead.
-type CredentialService struct {
- Options []option.RequestOption
-}
-
-// NewCredentialService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewCredentialService(opts ...option.RequestOption) (r *CredentialService) {
- r = &CredentialService{}
- r.Options = opts
- return
-}
-
-func (r *CredentialService) List(ctx context.Context, scope string, query CredentialListParams, opts ...option.RequestOption) (res *pagination.ConnectionsCursorPage[Connection], err error) {
- var raw *http.Response
- opts = slices.Concat(r.Options, opts)
- opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
- if scope == "" {
- err = errors.New("missing required scope parameter")
- return nil, err
- }
- path := fmt.Sprintf("credentials/%s", scope)
- cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
- if err != nil {
- return nil, err
- }
- err = cfg.Execute()
- if err != nil {
- return nil, err
- }
- res.SetPageConfig(cfg, raw)
- return res, nil
-}
-
-func (r *CredentialService) ListAutoPaging(ctx context.Context, scope string, query CredentialListParams, opts ...option.RequestOption) *pagination.ConnectionsCursorPageAutoPager[Connection] {
- return pagination.NewConnectionsCursorPageAutoPager(r.List(ctx, scope, query, opts...))
-}
-
-func (r *CredentialService) Delete(ctx context.Context, scope string, connectionID string, opts ...option.RequestOption) (res *CredentialDeleteResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if scope == "" {
- err = errors.New("missing required scope parameter")
- return nil, err
- }
- if connectionID == "" {
- err = errors.New("missing required connectionId parameter")
- return nil, err
- }
- path := fmt.Sprintf("credentials/%s/%s", scope, connectionID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *CredentialService) NewAPIKey(ctx context.Context, scope string, body CredentialNewAPIKeyParams, opts ...option.RequestOption) (res *Connection, err error) {
- opts = slices.Concat(r.Options, opts)
- if scope == "" {
- err = errors.New("missing required scope parameter")
- return nil, err
- }
- path := fmt.Sprintf("credentials/%s/api-keys", scope)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-type Connection struct {
- ID string `json:"id" api:"required"`
- AccountLabel string `json:"accountLabel" api:"required,nullable"`
- CreatedAt string `json:"createdAt" api:"required"`
- Provider CredentialProvider `json:"provider" api:"required"`
- // Reusable credential connection scope.
- Scope string `json:"scope" api:"required"`
- Scopes []string `json:"scopes" api:"required"`
- Type CredentialType `json:"type" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- JSON connectionJSON `json:"-"`
-}
-
-// connectionJSON contains the JSON metadata for the struct [Connection]
-type connectionJSON struct {
- ID apijson.Field
- AccountLabel apijson.Field
- CreatedAt apijson.Field
- Provider apijson.Field
- Scope apijson.Field
- Scopes apijson.Field
- Type apijson.Field
- UpdatedAt apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *Connection) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r connectionJSON) RawJSON() string {
- return r.raw
-}
-
-type CredentialProvider string
-
-const (
- CredentialProviderGoogle CredentialProvider = "google"
- CredentialProviderGitHub CredentialProvider = "github"
- CredentialProviderSlack CredentialProvider = "slack"
- CredentialProviderLinear CredentialProvider = "linear"
- CredentialProviderNotion CredentialProvider = "notion"
- CredentialProviderCustom CredentialProvider = "custom"
- CredentialProviderWebhook CredentialProvider = "webhook"
-)
-
-func (r CredentialProvider) IsKnown() bool {
- switch r {
- case CredentialProviderGoogle, CredentialProviderGitHub, CredentialProviderSlack, CredentialProviderLinear, CredentialProviderNotion, CredentialProviderCustom, CredentialProviderWebhook:
- return true
- }
- return false
-}
-
-type CredentialType string
-
-const (
- CredentialTypeOAuth CredentialType = "oauth"
- CredentialTypeAPIKey CredentialType = "api_key"
-)
-
-func (r CredentialType) IsKnown() bool {
- switch r {
- case CredentialTypeOAuth, CredentialTypeAPIKey:
- return true
- }
- return false
-}
-
-type CredentialDeleteResponse struct {
- Success CredentialDeleteResponseSuccess `json:"success" api:"required"`
- JSON credentialDeleteResponseJSON `json:"-"`
-}
-
-// credentialDeleteResponseJSON contains the JSON metadata for the struct
-// [CredentialDeleteResponse]
-type credentialDeleteResponseJSON struct {
- Success apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CredentialDeleteResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r credentialDeleteResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type CredentialDeleteResponseSuccess bool
-
-const (
- CredentialDeleteResponseSuccessTrue CredentialDeleteResponseSuccess = true
-)
-
-func (r CredentialDeleteResponseSuccess) IsKnown() bool {
- switch r {
- case CredentialDeleteResponseSuccessTrue:
- return true
- }
- return false
-}
-
-type CredentialListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [CredentialListParams]'s query parameters as `url.Values`.
-func (r CredentialListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type CredentialNewAPIKeyParams struct {
- // API key secret. It is stored securely and is not returned.
- APIKey param.Field[string] `json:"apiKey" api:"required"`
- // Credential provider to store an API key for.
- Provider param.Field[string] `json:"provider" api:"required"`
- // Optional human-readable account label.
- AccountLabel param.Field[string] `json:"accountLabel"`
-}
-
-func (r CredentialNewAPIKeyParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
diff --git a/credential_test.go b/credential_test.go
deleted file mode 100644
index bf1c23a..0000000
--- a/credential_test.go
+++ /dev/null
@@ -1,99 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestCredentialListWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Credentials.List(
- context.TODO(),
- "env:org_abc123:fleet_abc123",
- cercago.CredentialListParams{
- Cursor: cercago.F("cursor_abc123"),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestCredentialDelete(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Credentials.Delete(
- context.TODO(),
- "env:org_abc123:fleet_abc123",
- "env:org_abc123:fleet_abc123::conn_abc123",
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestCredentialNewAPIKeyWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Credentials.NewAPIKey(
- context.TODO(),
- "env:org_abc123:fleet_abc123",
- cercago.CredentialNewAPIKeyParams{
- APIKey: cercago.F("sk_live_..."),
- Provider: cercago.F("custom"),
- AccountLabel: cercago.F("primary"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/event.go b/event.go
index 2003088..5ed26a0 100644
--- a/event.go
+++ b/event.go
@@ -8,6 +8,7 @@ import (
"fmt"
"net/http"
"net/url"
+ "reflect"
"slices"
"github.com/matrices/cerca-go/internal/apijson"
@@ -17,6 +18,7 @@ import (
"github.com/matrices/cerca-go/option"
"github.com/matrices/cerca-go/packages/pagination"
"github.com/matrices/cerca-go/shared"
+ "github.com/tidwall/gjson"
)
// EventService contains methods and other services that help with interacting with
@@ -38,6 +40,7 @@ func NewEventService(opts ...option.RequestOption) (r *EventService) {
return
}
+// Events
func (r *EventService) ListForAgent(ctx context.Context, agentID string, query EventListForAgentParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -59,10 +62,12 @@ func (r *EventService) ListForAgent(ctx context.Context, agentID string, query E
return res, nil
}
+// Events
func (r *EventService) ListForAgentAutoPaging(ctx context.Context, agentID string, query EventListForAgentParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
return pagination.NewEventsCursorPageAutoPager(r.ListForAgent(ctx, agentID, query, opts...))
}
+// Events
func (r *EventService) ListForFleet(ctx context.Context, fleetID string, query EventListForFleetParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -84,10 +89,12 @@ func (r *EventService) ListForFleet(ctx context.Context, fleetID string, query E
return res, nil
}
+// Events
func (r *EventService) ListForFleetAutoPaging(ctx context.Context, fleetID string, query EventListForFleetParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
return pagination.NewEventsCursorPageAutoPager(r.ListForFleet(ctx, fleetID, query, opts...))
}
+// Events
func (r *EventService) ListForThread(ctx context.Context, agentID string, threadID string, query EventListForThreadParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -113,6 +120,7 @@ func (r *EventService) ListForThread(ctx context.Context, agentID string, thread
return res, nil
}
+// Events
func (r *EventService) ListForThreadAutoPaging(ctx context.Context, agentID string, threadID string, query EventListForThreadParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
return pagination.NewEventsCursorPageAutoPager(r.ListForThread(ctx, agentID, threadID, query, opts...))
}
@@ -168,15 +176,37 @@ func (r *EventService) SubscribeThread(ctx context.Context, agentID string, thre
}
type RuntimeWebhookEvent struct {
- ID string `json:"id" api:"required"`
- AgentID string `json:"agentId" api:"required"`
- Data map[string]interface{} `json:"data" api:"required"`
- Event RuntimeWebhookEventType `json:"event" api:"required"`
- FleetID string `json:"fleetId" api:"required"`
- OrgID string `json:"orgId" api:"required"`
- ThreadID string `json:"threadId" api:"required,nullable"`
- Timestamp string `json:"timestamp" api:"required"`
- JSON runtimeWebhookEventJSON `json:"-"`
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ // This field can have the runtime type of
+ // [RuntimeWebhookEventAgentCreatedWebhookEventData],
+ // [RuntimeWebhookEventAgentUpdatedWebhookEventData],
+ // [RuntimeWebhookEventAgentDeletedWebhookEventData],
+ // [RuntimeWebhookEventThreadCreatedWebhookEventData],
+ // [RuntimeWebhookEventThreadStatusChangedWebhookEventData],
+ // [RuntimeWebhookEventThreadCompletedWebhookEventData],
+ // [RuntimeWebhookEventThreadFailedWebhookEventData],
+ // [RuntimeWebhookEventTurnCreatedWebhookEventData],
+ // [RuntimeWebhookEventTurnCompletedWebhookEventData],
+ // [RuntimeWebhookEventTurnFailedWebhookEventData],
+ // [RuntimeWebhookEventMessageCreatedWebhookEventData],
+ // [RuntimeWebhookEventApprovalRequestedWebhookEventData],
+ // [RuntimeWebhookEventApprovalResolvedWebhookEventData],
+ // [RuntimeWebhookEventApprovalGrantedWebhookEventData],
+ // [RuntimeWebhookEventScheduleCreatedWebhookEventData],
+ // [RuntimeWebhookEventScheduleDeletedWebhookEventData],
+ // [RuntimeWebhookEventScheduleTriggeredWebhookEventData],
+ // [RuntimeWebhookEventConnectionAttachedWebhookEventData],
+ // [RuntimeWebhookEventConnectionDetachedWebhookEventData],
+ // [RuntimeWebhookEventWebhookTestWebhookEventData].
+ Data interface{} `json:"data" api:"required"`
+ Event RuntimeWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventJSON `json:"-"`
+ union RuntimeWebhookEventUnion
}
// runtimeWebhookEventJSON contains the JSON metadata for the struct
@@ -194,42 +224,1973 @@ type runtimeWebhookEventJSON struct {
ExtraFields map[string]apijson.Field
}
+func (r runtimeWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
func (r *RuntimeWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ *r = RuntimeWebhookEvent{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [RuntimeWebhookEventUnion] interface which you can cast to the
+// specific types for more type safety.
+//
+// Possible runtime types of the union are
+// [RuntimeWebhookEventAgentCreatedWebhookEvent],
+// [RuntimeWebhookEventAgentUpdatedWebhookEvent],
+// [RuntimeWebhookEventAgentDeletedWebhookEvent],
+// [RuntimeWebhookEventThreadCreatedWebhookEvent],
+// [RuntimeWebhookEventThreadStatusChangedWebhookEvent],
+// [RuntimeWebhookEventThreadCompletedWebhookEvent],
+// [RuntimeWebhookEventThreadFailedWebhookEvent],
+// [RuntimeWebhookEventTurnCreatedWebhookEvent],
+// [RuntimeWebhookEventTurnCompletedWebhookEvent],
+// [RuntimeWebhookEventTurnFailedWebhookEvent],
+// [RuntimeWebhookEventMessageCreatedWebhookEvent],
+// [RuntimeWebhookEventApprovalRequestedWebhookEvent],
+// [RuntimeWebhookEventApprovalResolvedWebhookEvent],
+// [RuntimeWebhookEventApprovalGrantedWebhookEvent],
+// [RuntimeWebhookEventScheduleCreatedWebhookEvent],
+// [RuntimeWebhookEventScheduleDeletedWebhookEvent],
+// [RuntimeWebhookEventScheduleTriggeredWebhookEvent],
+// [RuntimeWebhookEventConnectionAttachedWebhookEvent],
+// [RuntimeWebhookEventConnectionDetachedWebhookEvent],
+// [RuntimeWebhookEventWebhookTestWebhookEvent].
+func (r RuntimeWebhookEvent) AsUnion() RuntimeWebhookEventUnion {
+ return r.union
+}
+
+// Union satisfied by [RuntimeWebhookEventAgentCreatedWebhookEvent],
+// [RuntimeWebhookEventAgentUpdatedWebhookEvent],
+// [RuntimeWebhookEventAgentDeletedWebhookEvent],
+// [RuntimeWebhookEventThreadCreatedWebhookEvent],
+// [RuntimeWebhookEventThreadStatusChangedWebhookEvent],
+// [RuntimeWebhookEventThreadCompletedWebhookEvent],
+// [RuntimeWebhookEventThreadFailedWebhookEvent],
+// [RuntimeWebhookEventTurnCreatedWebhookEvent],
+// [RuntimeWebhookEventTurnCompletedWebhookEvent],
+// [RuntimeWebhookEventTurnFailedWebhookEvent],
+// [RuntimeWebhookEventMessageCreatedWebhookEvent],
+// [RuntimeWebhookEventApprovalRequestedWebhookEvent],
+// [RuntimeWebhookEventApprovalResolvedWebhookEvent],
+// [RuntimeWebhookEventApprovalGrantedWebhookEvent],
+// [RuntimeWebhookEventScheduleCreatedWebhookEvent],
+// [RuntimeWebhookEventScheduleDeletedWebhookEvent],
+// [RuntimeWebhookEventScheduleTriggeredWebhookEvent],
+// [RuntimeWebhookEventConnectionAttachedWebhookEvent],
+// [RuntimeWebhookEventConnectionDetachedWebhookEvent] or
+// [RuntimeWebhookEventWebhookTestWebhookEvent].
+type RuntimeWebhookEventUnion interface {
+ implementsRuntimeWebhookEvent()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*RuntimeWebhookEventUnion)(nil)).Elem(),
+ "event",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventAgentCreatedWebhookEvent{}),
+ DiscriminatorValue: "agent.created",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventAgentUpdatedWebhookEvent{}),
+ DiscriminatorValue: "agent.updated",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventAgentDeletedWebhookEvent{}),
+ DiscriminatorValue: "agent.deleted",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventThreadCreatedWebhookEvent{}),
+ DiscriminatorValue: "thread.created",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventThreadStatusChangedWebhookEvent{}),
+ DiscriminatorValue: "thread.status.changed",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventThreadCompletedWebhookEvent{}),
+ DiscriminatorValue: "thread.completed",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventThreadFailedWebhookEvent{}),
+ DiscriminatorValue: "thread.failed",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventTurnCreatedWebhookEvent{}),
+ DiscriminatorValue: "turn.created",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventTurnCompletedWebhookEvent{}),
+ DiscriminatorValue: "turn.completed",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventTurnFailedWebhookEvent{}),
+ DiscriminatorValue: "turn.failed",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventMessageCreatedWebhookEvent{}),
+ DiscriminatorValue: "message.created",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventApprovalRequestedWebhookEvent{}),
+ DiscriminatorValue: "approval.requested",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventApprovalResolvedWebhookEvent{}),
+ DiscriminatorValue: "approval.resolved",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventApprovalGrantedWebhookEvent{}),
+ DiscriminatorValue: "approval.granted",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventScheduleCreatedWebhookEvent{}),
+ DiscriminatorValue: "schedule.created",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventScheduleDeletedWebhookEvent{}),
+ DiscriminatorValue: "schedule.deleted",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventScheduleTriggeredWebhookEvent{}),
+ DiscriminatorValue: "schedule.triggered",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventConnectionAttachedWebhookEvent{}),
+ DiscriminatorValue: "connection.attached",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventConnectionDetachedWebhookEvent{}),
+ DiscriminatorValue: "connection.detached",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(RuntimeWebhookEventWebhookTestWebhookEvent{}),
+ DiscriminatorValue: "webhook.test",
+ },
+ )
+}
+
+type RuntimeWebhookEventAgentCreatedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventAgentCreatedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventAgentCreatedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventAgentCreatedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventAgentCreatedWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventAgentCreatedWebhookEvent]
+type runtimeWebhookEventAgentCreatedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventAgentCreatedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r runtimeWebhookEventJSON) RawJSON() string {
+func (r runtimeWebhookEventAgentCreatedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventAgentCreatedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventAgentCreatedWebhookEventData struct {
+ Agent RuntimeWebhookEventAgentCreatedWebhookEventDataAgent `json:"agent" api:"required"`
+ JSON runtimeWebhookEventAgentCreatedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventAgentCreatedWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventAgentCreatedWebhookEventData]
+type runtimeWebhookEventAgentCreatedWebhookEventDataJSON struct {
+ Agent apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventAgentCreatedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventAgentCreatedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventAgentCreatedWebhookEventDataAgent struct {
+ ID string `json:"id" api:"required"`
+ Configuration Configuration `json:"configuration" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ // Arbitrary string metadata stored on an agent. Runtime enforces maximum key and
+ // value sizes.
+ Metadata Metadata `json:"metadata" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ UserID string `json:"userId" api:"required"`
+ Effective EffectiveConfiguration `json:"effective"`
+ JSON runtimeWebhookEventAgentCreatedWebhookEventDataAgentJSON `json:"-"`
+}
+
+// runtimeWebhookEventAgentCreatedWebhookEventDataAgentJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventAgentCreatedWebhookEventDataAgent]
+type runtimeWebhookEventAgentCreatedWebhookEventDataAgentJSON struct {
+ ID apijson.Field
+ Configuration apijson.Field
+ CreatedAt apijson.Field
+ FleetID apijson.Field
+ Metadata apijson.Field
+ OrgID apijson.Field
+ UpdatedAt apijson.Field
+ UserID apijson.Field
+ Effective apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventAgentCreatedWebhookEventDataAgent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventAgentCreatedWebhookEventDataAgentJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventAgentCreatedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventAgentCreatedWebhookEventEventAgentCreated RuntimeWebhookEventAgentCreatedWebhookEventEvent = "agent.created"
+)
+
+func (r RuntimeWebhookEventAgentCreatedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventAgentCreatedWebhookEventEventAgentCreated:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventAgentUpdatedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventAgentUpdatedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventAgentUpdatedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventAgentUpdatedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventAgentUpdatedWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventAgentUpdatedWebhookEvent]
+type runtimeWebhookEventAgentUpdatedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventAgentUpdatedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventAgentUpdatedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventAgentUpdatedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventAgentUpdatedWebhookEventData struct {
+ Agent RuntimeWebhookEventAgentUpdatedWebhookEventDataAgent `json:"agent" api:"required"`
+ Trigger RuntimeWebhookEventAgentUpdatedWebhookEventDataTrigger `json:"trigger" api:"required"`
+ JSON runtimeWebhookEventAgentUpdatedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventAgentUpdatedWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventAgentUpdatedWebhookEventData]
+type runtimeWebhookEventAgentUpdatedWebhookEventDataJSON struct {
+ Agent apijson.Field
+ Trigger apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventAgentUpdatedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventAgentUpdatedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventAgentUpdatedWebhookEventDataAgent struct {
+ ID string `json:"id" api:"required"`
+ Configuration Configuration `json:"configuration" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ // Arbitrary string metadata stored on an agent. Runtime enforces maximum key and
+ // value sizes.
+ Metadata Metadata `json:"metadata" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ UserID string `json:"userId" api:"required"`
+ Effective EffectiveConfiguration `json:"effective"`
+ JSON runtimeWebhookEventAgentUpdatedWebhookEventDataAgentJSON `json:"-"`
+}
+
+// runtimeWebhookEventAgentUpdatedWebhookEventDataAgentJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventAgentUpdatedWebhookEventDataAgent]
+type runtimeWebhookEventAgentUpdatedWebhookEventDataAgentJSON struct {
+ ID apijson.Field
+ Configuration apijson.Field
+ CreatedAt apijson.Field
+ FleetID apijson.Field
+ Metadata apijson.Field
+ OrgID apijson.Field
+ UpdatedAt apijson.Field
+ UserID apijson.Field
+ Effective apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventAgentUpdatedWebhookEventDataAgent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventAgentUpdatedWebhookEventDataAgentJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventAgentUpdatedWebhookEventDataTrigger string
+
+const (
+ RuntimeWebhookEventAgentUpdatedWebhookEventDataTriggerConfiguration RuntimeWebhookEventAgentUpdatedWebhookEventDataTrigger = "configuration"
+ RuntimeWebhookEventAgentUpdatedWebhookEventDataTriggerMetadata RuntimeWebhookEventAgentUpdatedWebhookEventDataTrigger = "metadata"
+)
+
+func (r RuntimeWebhookEventAgentUpdatedWebhookEventDataTrigger) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventAgentUpdatedWebhookEventDataTriggerConfiguration, RuntimeWebhookEventAgentUpdatedWebhookEventDataTriggerMetadata:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventAgentUpdatedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventAgentUpdatedWebhookEventEventAgentUpdated RuntimeWebhookEventAgentUpdatedWebhookEventEvent = "agent.updated"
+)
+
+func (r RuntimeWebhookEventAgentUpdatedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventAgentUpdatedWebhookEventEventAgentUpdated:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventAgentDeletedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventAgentDeletedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventAgentDeletedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventAgentDeletedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventAgentDeletedWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventAgentDeletedWebhookEvent]
+type runtimeWebhookEventAgentDeletedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventAgentDeletedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventAgentDeletedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventAgentDeletedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventAgentDeletedWebhookEventData struct {
+ AgentID string `json:"agentId" api:"required"`
+ JSON runtimeWebhookEventAgentDeletedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventAgentDeletedWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventAgentDeletedWebhookEventData]
+type runtimeWebhookEventAgentDeletedWebhookEventDataJSON struct {
+ AgentID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventAgentDeletedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventAgentDeletedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventAgentDeletedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventAgentDeletedWebhookEventEventAgentDeleted RuntimeWebhookEventAgentDeletedWebhookEventEvent = "agent.deleted"
+)
+
+func (r RuntimeWebhookEventAgentDeletedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventAgentDeletedWebhookEventEventAgentDeleted:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventThreadCreatedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventThreadCreatedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventThreadCreatedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventThreadCreatedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventThreadCreatedWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventThreadCreatedWebhookEvent]
+type runtimeWebhookEventThreadCreatedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventThreadCreatedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventThreadCreatedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventThreadCreatedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventThreadCreatedWebhookEventData struct {
+ Message string `json:"message" api:"required"`
+ Model string `json:"model" api:"required"`
+ JSON runtimeWebhookEventThreadCreatedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventThreadCreatedWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventThreadCreatedWebhookEventData]
+type runtimeWebhookEventThreadCreatedWebhookEventDataJSON struct {
+ Message apijson.Field
+ Model apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventThreadCreatedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventThreadCreatedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventThreadCreatedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventThreadCreatedWebhookEventEventThreadCreated RuntimeWebhookEventThreadCreatedWebhookEventEvent = "thread.created"
+)
+
+func (r RuntimeWebhookEventThreadCreatedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventThreadCreatedWebhookEventEventThreadCreated:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventThreadStatusChangedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventThreadStatusChangedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventThreadStatusChangedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventThreadStatusChangedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventThreadStatusChangedWebhookEventJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventThreadStatusChangedWebhookEvent]
+type runtimeWebhookEventThreadStatusChangedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventThreadStatusChangedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventThreadStatusChangedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventThreadStatusChangedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventThreadStatusChangedWebhookEventData struct {
+ Error string `json:"error" api:"required,nullable"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ PreviousStatus Status `json:"previousStatus" api:"required"`
+ Result string `json:"result" api:"required,nullable"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ Status Status `json:"status" api:"required"`
+ JSON runtimeWebhookEventThreadStatusChangedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventThreadStatusChangedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventThreadStatusChangedWebhookEventData]
+type runtimeWebhookEventThreadStatusChangedWebhookEventDataJSON struct {
+ Error apijson.Field
+ PreviousStatus apijson.Field
+ Result apijson.Field
+ Status apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventThreadStatusChangedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventThreadStatusChangedWebhookEventDataJSON) RawJSON() string {
return r.raw
}
-type RuntimeWebhookEventType string
+type RuntimeWebhookEventThreadStatusChangedWebhookEventEvent string
const (
- RuntimeWebhookEventTypeAgentCreated RuntimeWebhookEventType = "agent.created"
- RuntimeWebhookEventTypeAgentUpdated RuntimeWebhookEventType = "agent.updated"
- RuntimeWebhookEventTypeAgentDeleted RuntimeWebhookEventType = "agent.deleted"
- RuntimeWebhookEventTypeThreadCreated RuntimeWebhookEventType = "thread.created"
- RuntimeWebhookEventTypeThreadStatusChanged RuntimeWebhookEventType = "thread.status.changed"
- RuntimeWebhookEventTypeThreadCompleted RuntimeWebhookEventType = "thread.completed"
- RuntimeWebhookEventTypeThreadFailed RuntimeWebhookEventType = "thread.failed"
- RuntimeWebhookEventTypeTurnCreated RuntimeWebhookEventType = "turn.created"
- RuntimeWebhookEventTypeTurnCompleted RuntimeWebhookEventType = "turn.completed"
- RuntimeWebhookEventTypeTurnFailed RuntimeWebhookEventType = "turn.failed"
- RuntimeWebhookEventTypeMessageCreated RuntimeWebhookEventType = "message.created"
- RuntimeWebhookEventTypeApprovalRequested RuntimeWebhookEventType = "approval.requested"
- RuntimeWebhookEventTypeApprovalResolved RuntimeWebhookEventType = "approval.resolved"
- RuntimeWebhookEventTypeApprovalGranted RuntimeWebhookEventType = "approval.granted"
- RuntimeWebhookEventTypeScheduleCreated RuntimeWebhookEventType = "schedule.created"
- RuntimeWebhookEventTypeScheduleDeleted RuntimeWebhookEventType = "schedule.deleted"
- RuntimeWebhookEventTypeScheduleTriggered RuntimeWebhookEventType = "schedule.triggered"
- RuntimeWebhookEventTypeConnectionAttached RuntimeWebhookEventType = "connection.attached"
- RuntimeWebhookEventTypeConnectionDetached RuntimeWebhookEventType = "connection.detached"
- RuntimeWebhookEventTypeWebhookTest RuntimeWebhookEventType = "webhook.test"
-)
-
-func (r RuntimeWebhookEventType) IsKnown() bool {
+ RuntimeWebhookEventThreadStatusChangedWebhookEventEventThreadStatusChanged RuntimeWebhookEventThreadStatusChangedWebhookEventEvent = "thread.status.changed"
+)
+
+func (r RuntimeWebhookEventThreadStatusChangedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventThreadStatusChangedWebhookEventEventThreadStatusChanged:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventThreadCompletedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventThreadCompletedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventThreadCompletedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventThreadCompletedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventThreadCompletedWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventThreadCompletedWebhookEvent]
+type runtimeWebhookEventThreadCompletedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventThreadCompletedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventThreadCompletedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventThreadCompletedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventThreadCompletedWebhookEventData struct {
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ PreviousStatus Status `json:"previousStatus" api:"required"`
+ Result string `json:"result" api:"required"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ Status Status `json:"status" api:"required"`
+ JSON runtimeWebhookEventThreadCompletedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventThreadCompletedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventThreadCompletedWebhookEventData]
+type runtimeWebhookEventThreadCompletedWebhookEventDataJSON struct {
+ PreviousStatus apijson.Field
+ Result apijson.Field
+ Status apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventThreadCompletedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventThreadCompletedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventThreadCompletedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventThreadCompletedWebhookEventEventThreadCompleted RuntimeWebhookEventThreadCompletedWebhookEventEvent = "thread.completed"
+)
+
+func (r RuntimeWebhookEventThreadCompletedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventThreadCompletedWebhookEventEventThreadCompleted:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventThreadFailedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventThreadFailedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventThreadFailedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventThreadFailedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventThreadFailedWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventThreadFailedWebhookEvent]
+type runtimeWebhookEventThreadFailedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventThreadFailedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventThreadFailedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventThreadFailedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventThreadFailedWebhookEventData struct {
+ Error string `json:"error" api:"required"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ PreviousStatus Status `json:"previousStatus" api:"required"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ Status Status `json:"status" api:"required"`
+ JSON runtimeWebhookEventThreadFailedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventThreadFailedWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventThreadFailedWebhookEventData]
+type runtimeWebhookEventThreadFailedWebhookEventDataJSON struct {
+ Error apijson.Field
+ PreviousStatus apijson.Field
+ Status apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventThreadFailedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventThreadFailedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventThreadFailedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventThreadFailedWebhookEventEventThreadFailed RuntimeWebhookEventThreadFailedWebhookEventEvent = "thread.failed"
+)
+
+func (r RuntimeWebhookEventThreadFailedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventThreadFailedWebhookEventEventThreadFailed:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventTurnCreatedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventTurnCreatedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventTurnCreatedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventTurnCreatedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventTurnCreatedWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventTurnCreatedWebhookEvent]
+type runtimeWebhookEventTurnCreatedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventTurnCreatedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventTurnCreatedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventTurnCreatedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventTurnCreatedWebhookEventData struct {
+ Message string `json:"message" api:"required"`
+ Seq float64 `json:"seq" api:"required"`
+ StartedAt string `json:"startedAt" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ JSON runtimeWebhookEventTurnCreatedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventTurnCreatedWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventTurnCreatedWebhookEventData]
+type runtimeWebhookEventTurnCreatedWebhookEventDataJSON struct {
+ Message apijson.Field
+ Seq apijson.Field
+ StartedAt apijson.Field
+ TurnID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventTurnCreatedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventTurnCreatedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventTurnCreatedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventTurnCreatedWebhookEventEventTurnCreated RuntimeWebhookEventTurnCreatedWebhookEventEvent = "turn.created"
+)
+
+func (r RuntimeWebhookEventTurnCreatedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventTurnCreatedWebhookEventEventTurnCreated:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventTurnCompletedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventTurnCompletedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventTurnCompletedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventTurnCompletedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventTurnCompletedWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventTurnCompletedWebhookEvent]
+type runtimeWebhookEventTurnCompletedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventTurnCompletedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventTurnCompletedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventTurnCompletedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventTurnCompletedWebhookEventData struct {
+ CompletedAt string `json:"completedAt" api:"required"`
+ Error string `json:"error" api:"required,nullable"`
+ Result string `json:"result" api:"required,nullable"`
+ Seq float64 `json:"seq" api:"required"`
+ Status RuntimeWebhookEventTurnCompletedWebhookEventDataStatus `json:"status" api:"required"`
+ TokenUsage TokenUsage `json:"tokenUsage" api:"required,nullable"`
+ TurnID string `json:"turnId" api:"required"`
+ JSON runtimeWebhookEventTurnCompletedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventTurnCompletedWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventTurnCompletedWebhookEventData]
+type runtimeWebhookEventTurnCompletedWebhookEventDataJSON struct {
+ CompletedAt apijson.Field
+ Error apijson.Field
+ Result apijson.Field
+ Seq apijson.Field
+ Status apijson.Field
+ TokenUsage apijson.Field
+ TurnID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventTurnCompletedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventTurnCompletedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventTurnCompletedWebhookEventDataStatus string
+
+const (
+ RuntimeWebhookEventTurnCompletedWebhookEventDataStatusCompleted RuntimeWebhookEventTurnCompletedWebhookEventDataStatus = "completed"
+)
+
+func (r RuntimeWebhookEventTurnCompletedWebhookEventDataStatus) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventTurnCompletedWebhookEventDataStatusCompleted:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventTurnCompletedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventTurnCompletedWebhookEventEventTurnCompleted RuntimeWebhookEventTurnCompletedWebhookEventEvent = "turn.completed"
+)
+
+func (r RuntimeWebhookEventTurnCompletedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventTurnCompletedWebhookEventEventTurnCompleted:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventTurnFailedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventTurnFailedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventTurnFailedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventTurnFailedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventTurnFailedWebhookEventJSON contains the JSON metadata for the
+// struct [RuntimeWebhookEventTurnFailedWebhookEvent]
+type runtimeWebhookEventTurnFailedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventTurnFailedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventTurnFailedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventTurnFailedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventTurnFailedWebhookEventData struct {
+ CompletedAt string `json:"completedAt" api:"required"`
+ Error string `json:"error" api:"required,nullable"`
+ Result string `json:"result" api:"required,nullable"`
+ Seq float64 `json:"seq" api:"required"`
+ Status RuntimeWebhookEventTurnFailedWebhookEventDataStatus `json:"status" api:"required"`
+ TokenUsage TokenUsage `json:"tokenUsage" api:"required,nullable"`
+ TurnID string `json:"turnId" api:"required"`
+ JSON runtimeWebhookEventTurnFailedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventTurnFailedWebhookEventDataJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventTurnFailedWebhookEventData]
+type runtimeWebhookEventTurnFailedWebhookEventDataJSON struct {
+ CompletedAt apijson.Field
+ Error apijson.Field
+ Result apijson.Field
+ Seq apijson.Field
+ Status apijson.Field
+ TokenUsage apijson.Field
+ TurnID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventTurnFailedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventTurnFailedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventTurnFailedWebhookEventDataStatus string
+
+const (
+ RuntimeWebhookEventTurnFailedWebhookEventDataStatusFailed RuntimeWebhookEventTurnFailedWebhookEventDataStatus = "failed"
+)
+
+func (r RuntimeWebhookEventTurnFailedWebhookEventDataStatus) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventTurnFailedWebhookEventDataStatusFailed:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventTurnFailedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventTurnFailedWebhookEventEventTurnFailed RuntimeWebhookEventTurnFailedWebhookEventEvent = "turn.failed"
+)
+
+func (r RuntimeWebhookEventTurnFailedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventTurnFailedWebhookEventEventTurnFailed:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventMessageCreatedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventMessageCreatedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventMessageCreatedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventMessageCreatedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventMessageCreatedWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventMessageCreatedWebhookEvent]
+type runtimeWebhookEventMessageCreatedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventMessageCreatedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventMessageCreatedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventMessageCreatedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventMessageCreatedWebhookEventData struct {
+ CreatedAt string `json:"createdAt" api:"required"`
+ Role RuntimeWebhookEventMessageCreatedWebhookEventDataRole `json:"role" api:"required"`
+ Seq float64 `json:"seq" api:"required"`
+ TurnID string `json:"turnId" api:"required,nullable"`
+ JSON runtimeWebhookEventMessageCreatedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventMessageCreatedWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventMessageCreatedWebhookEventData]
+type runtimeWebhookEventMessageCreatedWebhookEventDataJSON struct {
+ CreatedAt apijson.Field
+ Role apijson.Field
+ Seq apijson.Field
+ TurnID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventMessageCreatedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventMessageCreatedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventMessageCreatedWebhookEventDataRole string
+
+const (
+ RuntimeWebhookEventMessageCreatedWebhookEventDataRoleUser RuntimeWebhookEventMessageCreatedWebhookEventDataRole = "user"
+ RuntimeWebhookEventMessageCreatedWebhookEventDataRoleAssistant RuntimeWebhookEventMessageCreatedWebhookEventDataRole = "assistant"
+)
+
+func (r RuntimeWebhookEventMessageCreatedWebhookEventDataRole) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventMessageCreatedWebhookEventDataRoleUser, RuntimeWebhookEventMessageCreatedWebhookEventDataRoleAssistant:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventMessageCreatedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventMessageCreatedWebhookEventEventMessageCreated RuntimeWebhookEventMessageCreatedWebhookEventEvent = "message.created"
+)
+
+func (r RuntimeWebhookEventMessageCreatedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventMessageCreatedWebhookEventEventMessageCreated:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventApprovalRequestedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventApprovalRequestedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventApprovalRequestedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventApprovalRequestedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventApprovalRequestedWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventApprovalRequestedWebhookEvent]
+type runtimeWebhookEventApprovalRequestedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventApprovalRequestedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventApprovalRequestedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventApprovalRequestedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventApprovalRequestedWebhookEventData struct {
+ Approval RuntimeWebhookEventApprovalRequestedWebhookEventDataApproval `json:"approval" api:"required"`
+ JSON runtimeWebhookEventApprovalRequestedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventApprovalRequestedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventApprovalRequestedWebhookEventData]
+type runtimeWebhookEventApprovalRequestedWebhookEventDataJSON struct {
+ Approval apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventApprovalRequestedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventApprovalRequestedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventApprovalRequestedWebhookEventDataApproval struct {
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ // JSON value payload. Generated SDKs may expose this as unknown or Any.
+ Input interface{} `json:"input" api:"required"`
+ ResolvedAt string `json:"resolvedAt" api:"required,nullable"`
+ RuntimeToolName shared.ToolName `json:"runtimeToolName" api:"required"`
+ Status RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatus `json:"status" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ TimeoutAt string `json:"timeoutAt" api:"required,nullable"`
+ TimeoutMs float64 `json:"timeoutMs" api:"required,nullable"`
+ ToolIndex float64 `json:"toolIndex" api:"required"`
+ ToolName string `json:"toolName" api:"required"`
+ ToolUseID string `json:"toolUseId" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ ToolSourceID string `json:"toolSourceId"`
+ ToolSourceVersion float64 `json:"toolSourceVersion"`
+ JSON runtimeWebhookEventApprovalRequestedWebhookEventDataApprovalJSON `json:"-"`
+}
+
+// runtimeWebhookEventApprovalRequestedWebhookEventDataApprovalJSON contains the
+// JSON metadata for the struct
+// [RuntimeWebhookEventApprovalRequestedWebhookEventDataApproval]
+type runtimeWebhookEventApprovalRequestedWebhookEventDataApprovalJSON struct {
+ ID apijson.Field
+ CreatedAt apijson.Field
+ Input apijson.Field
+ ResolvedAt apijson.Field
+ RuntimeToolName apijson.Field
+ Status apijson.Field
+ ThreadID apijson.Field
+ TimeoutAt apijson.Field
+ TimeoutMs apijson.Field
+ ToolIndex apijson.Field
+ ToolName apijson.Field
+ ToolUseID apijson.Field
+ TurnID apijson.Field
+ ToolSourceID apijson.Field
+ ToolSourceVersion apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventApprovalRequestedWebhookEventDataApproval) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventApprovalRequestedWebhookEventDataApprovalJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatus string
+
+const (
+ RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusPending RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatus = "pending"
+ RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusApproved RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatus = "approved"
+ RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusDenied RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatus = "denied"
+ RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusCancelled RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatus = "cancelled"
+ RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusTimedOut RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatus = "timed_out"
+)
+
+func (r RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatus) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusPending, RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusApproved, RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusDenied, RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusCancelled, RuntimeWebhookEventApprovalRequestedWebhookEventDataApprovalStatusTimedOut:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventApprovalRequestedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventApprovalRequestedWebhookEventEventApprovalRequested RuntimeWebhookEventApprovalRequestedWebhookEventEvent = "approval.requested"
+)
+
+func (r RuntimeWebhookEventApprovalRequestedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventApprovalRequestedWebhookEventEventApprovalRequested:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventApprovalResolvedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventApprovalResolvedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventApprovalResolvedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventApprovalResolvedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventApprovalResolvedWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventApprovalResolvedWebhookEvent]
+type runtimeWebhookEventApprovalResolvedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventApprovalResolvedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventApprovalResolvedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventApprovalResolvedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventApprovalResolvedWebhookEventData struct {
+ ApprovalID string `json:"approvalId" api:"required"`
+ Decision RuntimeWebhookEventApprovalResolvedWebhookEventDataDecision `json:"decision" api:"required"`
+ JSON runtimeWebhookEventApprovalResolvedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventApprovalResolvedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventApprovalResolvedWebhookEventData]
+type runtimeWebhookEventApprovalResolvedWebhookEventDataJSON struct {
+ ApprovalID apijson.Field
+ Decision apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventApprovalResolvedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventApprovalResolvedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventApprovalResolvedWebhookEventDataDecision string
+
+const (
+ RuntimeWebhookEventApprovalResolvedWebhookEventDataDecisionApproved RuntimeWebhookEventApprovalResolvedWebhookEventDataDecision = "approved"
+ RuntimeWebhookEventApprovalResolvedWebhookEventDataDecisionDenied RuntimeWebhookEventApprovalResolvedWebhookEventDataDecision = "denied"
+ RuntimeWebhookEventApprovalResolvedWebhookEventDataDecisionTimedOut RuntimeWebhookEventApprovalResolvedWebhookEventDataDecision = "timed_out"
+ RuntimeWebhookEventApprovalResolvedWebhookEventDataDecisionCancelled RuntimeWebhookEventApprovalResolvedWebhookEventDataDecision = "cancelled"
+)
+
+func (r RuntimeWebhookEventApprovalResolvedWebhookEventDataDecision) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventApprovalResolvedWebhookEventDataDecisionApproved, RuntimeWebhookEventApprovalResolvedWebhookEventDataDecisionDenied, RuntimeWebhookEventApprovalResolvedWebhookEventDataDecisionTimedOut, RuntimeWebhookEventApprovalResolvedWebhookEventDataDecisionCancelled:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventApprovalResolvedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventApprovalResolvedWebhookEventEventApprovalResolved RuntimeWebhookEventApprovalResolvedWebhookEventEvent = "approval.resolved"
+)
+
+func (r RuntimeWebhookEventApprovalResolvedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventApprovalResolvedWebhookEventEventApprovalResolved:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventApprovalGrantedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventApprovalGrantedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventApprovalGrantedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventApprovalGrantedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventApprovalGrantedWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventApprovalGrantedWebhookEvent]
+type runtimeWebhookEventApprovalGrantedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventApprovalGrantedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventApprovalGrantedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventApprovalGrantedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventApprovalGrantedWebhookEventData struct {
+ GrantID string `json:"grantId" api:"required"`
+ Scope RuntimeWebhookEventApprovalGrantedWebhookEventDataScope `json:"scope" api:"required"`
+ ToolName string `json:"toolName" api:"required"`
+ ThreadID string `json:"threadId"`
+ JSON runtimeWebhookEventApprovalGrantedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventApprovalGrantedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventApprovalGrantedWebhookEventData]
+type runtimeWebhookEventApprovalGrantedWebhookEventDataJSON struct {
+ GrantID apijson.Field
+ Scope apijson.Field
+ ToolName apijson.Field
+ ThreadID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventApprovalGrantedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventApprovalGrantedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventApprovalGrantedWebhookEventDataScope string
+
+const (
+ RuntimeWebhookEventApprovalGrantedWebhookEventDataScopeThread RuntimeWebhookEventApprovalGrantedWebhookEventDataScope = "thread"
+ RuntimeWebhookEventApprovalGrantedWebhookEventDataScopeAgent RuntimeWebhookEventApprovalGrantedWebhookEventDataScope = "agent"
+)
+
+func (r RuntimeWebhookEventApprovalGrantedWebhookEventDataScope) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventApprovalGrantedWebhookEventDataScopeThread, RuntimeWebhookEventApprovalGrantedWebhookEventDataScopeAgent:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventApprovalGrantedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventApprovalGrantedWebhookEventEventApprovalGranted RuntimeWebhookEventApprovalGrantedWebhookEventEvent = "approval.granted"
+)
+
+func (r RuntimeWebhookEventApprovalGrantedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventApprovalGrantedWebhookEventEventApprovalGranted:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventScheduleCreatedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventScheduleCreatedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventScheduleCreatedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventScheduleCreatedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventScheduleCreatedWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventScheduleCreatedWebhookEvent]
+type runtimeWebhookEventScheduleCreatedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventScheduleCreatedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventScheduleCreatedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventScheduleCreatedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventScheduleCreatedWebhookEventData struct {
+ Name string `json:"name" api:"required"`
+ ScheduleID string `json:"scheduleId" api:"required"`
+ Cron string `json:"cron"`
+ RunAt string `json:"runAt"`
+ JSON runtimeWebhookEventScheduleCreatedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventScheduleCreatedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventScheduleCreatedWebhookEventData]
+type runtimeWebhookEventScheduleCreatedWebhookEventDataJSON struct {
+ Name apijson.Field
+ ScheduleID apijson.Field
+ Cron apijson.Field
+ RunAt apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventScheduleCreatedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventScheduleCreatedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventScheduleCreatedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventScheduleCreatedWebhookEventEventScheduleCreated RuntimeWebhookEventScheduleCreatedWebhookEventEvent = "schedule.created"
+)
+
+func (r RuntimeWebhookEventScheduleCreatedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventScheduleCreatedWebhookEventEventScheduleCreated:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventScheduleDeletedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventScheduleDeletedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventScheduleDeletedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventScheduleDeletedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventScheduleDeletedWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventScheduleDeletedWebhookEvent]
+type runtimeWebhookEventScheduleDeletedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventScheduleDeletedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventScheduleDeletedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventScheduleDeletedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventScheduleDeletedWebhookEventData struct {
+ ScheduleID string `json:"scheduleId" api:"required"`
+ JSON runtimeWebhookEventScheduleDeletedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventScheduleDeletedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventScheduleDeletedWebhookEventData]
+type runtimeWebhookEventScheduleDeletedWebhookEventDataJSON struct {
+ ScheduleID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventScheduleDeletedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventScheduleDeletedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventScheduleDeletedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventScheduleDeletedWebhookEventEventScheduleDeleted RuntimeWebhookEventScheduleDeletedWebhookEventEvent = "schedule.deleted"
+)
+
+func (r RuntimeWebhookEventScheduleDeletedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventScheduleDeletedWebhookEventEventScheduleDeleted:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventScheduleTriggeredWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventScheduleTriggeredWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventScheduleTriggeredWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventScheduleTriggeredWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventScheduleTriggeredWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventScheduleTriggeredWebhookEvent]
+type runtimeWebhookEventScheduleTriggeredWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventScheduleTriggeredWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventScheduleTriggeredWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventScheduleTriggeredWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventScheduleTriggeredWebhookEventData struct {
+ ScheduleID string `json:"scheduleId" api:"required"`
+ ThreadID string `json:"threadId" api:"required"`
+ JSON runtimeWebhookEventScheduleTriggeredWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventScheduleTriggeredWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventScheduleTriggeredWebhookEventData]
+type runtimeWebhookEventScheduleTriggeredWebhookEventDataJSON struct {
+ ScheduleID apijson.Field
+ ThreadID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventScheduleTriggeredWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventScheduleTriggeredWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventScheduleTriggeredWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventScheduleTriggeredWebhookEventEventScheduleTriggered RuntimeWebhookEventScheduleTriggeredWebhookEventEvent = "schedule.triggered"
+)
+
+func (r RuntimeWebhookEventScheduleTriggeredWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventScheduleTriggeredWebhookEventEventScheduleTriggered:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventConnectionAttachedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventConnectionAttachedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventConnectionAttachedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventConnectionAttachedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventConnectionAttachedWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventConnectionAttachedWebhookEvent]
+type runtimeWebhookEventConnectionAttachedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventConnectionAttachedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventConnectionAttachedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventConnectionAttachedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventConnectionAttachedWebhookEventData struct {
+ ConnectionID string `json:"connectionId" api:"required"`
+ Provider string `json:"provider" api:"required"`
+ JSON runtimeWebhookEventConnectionAttachedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventConnectionAttachedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventConnectionAttachedWebhookEventData]
+type runtimeWebhookEventConnectionAttachedWebhookEventDataJSON struct {
+ ConnectionID apijson.Field
+ Provider apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventConnectionAttachedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventConnectionAttachedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventConnectionAttachedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventConnectionAttachedWebhookEventEventConnectionAttached RuntimeWebhookEventConnectionAttachedWebhookEventEvent = "connection.attached"
+)
+
+func (r RuntimeWebhookEventConnectionAttachedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventConnectionAttachedWebhookEventEventConnectionAttached:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventConnectionDetachedWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventConnectionDetachedWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventConnectionDetachedWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventConnectionDetachedWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventConnectionDetachedWebhookEventJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventConnectionDetachedWebhookEvent]
+type runtimeWebhookEventConnectionDetachedWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventConnectionDetachedWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventConnectionDetachedWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventConnectionDetachedWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventConnectionDetachedWebhookEventData struct {
+ ConnectionID string `json:"connectionId" api:"required"`
+ Provider string `json:"provider" api:"required"`
+ JSON runtimeWebhookEventConnectionDetachedWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventConnectionDetachedWebhookEventDataJSON contains the JSON
+// metadata for the struct [RuntimeWebhookEventConnectionDetachedWebhookEventData]
+type runtimeWebhookEventConnectionDetachedWebhookEventDataJSON struct {
+ ConnectionID apijson.Field
+ Provider apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventConnectionDetachedWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventConnectionDetachedWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventConnectionDetachedWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventConnectionDetachedWebhookEventEventConnectionDetached RuntimeWebhookEventConnectionDetachedWebhookEventEvent = "connection.detached"
+)
+
+func (r RuntimeWebhookEventConnectionDetachedWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventConnectionDetachedWebhookEventEventConnectionDetached:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventWebhookTestWebhookEvent struct {
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ Data RuntimeWebhookEventWebhookTestWebhookEventData `json:"data" api:"required"`
+ Event RuntimeWebhookEventWebhookTestWebhookEventEvent `json:"event" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ OrgID string `json:"orgId" api:"required"`
+ ThreadID string `json:"threadId" api:"required,nullable"`
+ Timestamp string `json:"timestamp" api:"required"`
+ JSON runtimeWebhookEventWebhookTestWebhookEventJSON `json:"-"`
+}
+
+// runtimeWebhookEventWebhookTestWebhookEventJSON contains the JSON metadata for
+// the struct [RuntimeWebhookEventWebhookTestWebhookEvent]
+type runtimeWebhookEventWebhookTestWebhookEventJSON struct {
+ ID apijson.Field
+ AgentID apijson.Field
+ Data apijson.Field
+ Event apijson.Field
+ FleetID apijson.Field
+ OrgID apijson.Field
+ ThreadID apijson.Field
+ Timestamp apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventWebhookTestWebhookEvent) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventWebhookTestWebhookEventJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r RuntimeWebhookEventWebhookTestWebhookEvent) implementsRuntimeWebhookEvent() {}
+
+type RuntimeWebhookEventWebhookTestWebhookEventData struct {
+ JSON runtimeWebhookEventWebhookTestWebhookEventDataJSON `json:"-"`
+}
+
+// runtimeWebhookEventWebhookTestWebhookEventDataJSON contains the JSON metadata
+// for the struct [RuntimeWebhookEventWebhookTestWebhookEventData]
+type runtimeWebhookEventWebhookTestWebhookEventDataJSON struct {
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RuntimeWebhookEventWebhookTestWebhookEventData) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r runtimeWebhookEventWebhookTestWebhookEventDataJSON) RawJSON() string {
+ return r.raw
+}
+
+type RuntimeWebhookEventWebhookTestWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventWebhookTestWebhookEventEventWebhookTest RuntimeWebhookEventWebhookTestWebhookEventEvent = "webhook.test"
+)
+
+func (r RuntimeWebhookEventWebhookTestWebhookEventEvent) IsKnown() bool {
+ switch r {
+ case RuntimeWebhookEventWebhookTestWebhookEventEventWebhookTest:
+ return true
+ }
+ return false
+}
+
+type RuntimeWebhookEventEvent string
+
+const (
+ RuntimeWebhookEventEventAgentCreated RuntimeWebhookEventEvent = "agent.created"
+ RuntimeWebhookEventEventAgentUpdated RuntimeWebhookEventEvent = "agent.updated"
+ RuntimeWebhookEventEventAgentDeleted RuntimeWebhookEventEvent = "agent.deleted"
+ RuntimeWebhookEventEventThreadCreated RuntimeWebhookEventEvent = "thread.created"
+ RuntimeWebhookEventEventThreadStatusChanged RuntimeWebhookEventEvent = "thread.status.changed"
+ RuntimeWebhookEventEventThreadCompleted RuntimeWebhookEventEvent = "thread.completed"
+ RuntimeWebhookEventEventThreadFailed RuntimeWebhookEventEvent = "thread.failed"
+ RuntimeWebhookEventEventTurnCreated RuntimeWebhookEventEvent = "turn.created"
+ RuntimeWebhookEventEventTurnCompleted RuntimeWebhookEventEvent = "turn.completed"
+ RuntimeWebhookEventEventTurnFailed RuntimeWebhookEventEvent = "turn.failed"
+ RuntimeWebhookEventEventMessageCreated RuntimeWebhookEventEvent = "message.created"
+ RuntimeWebhookEventEventApprovalRequested RuntimeWebhookEventEvent = "approval.requested"
+ RuntimeWebhookEventEventApprovalResolved RuntimeWebhookEventEvent = "approval.resolved"
+ RuntimeWebhookEventEventApprovalGranted RuntimeWebhookEventEvent = "approval.granted"
+ RuntimeWebhookEventEventScheduleCreated RuntimeWebhookEventEvent = "schedule.created"
+ RuntimeWebhookEventEventScheduleDeleted RuntimeWebhookEventEvent = "schedule.deleted"
+ RuntimeWebhookEventEventScheduleTriggered RuntimeWebhookEventEvent = "schedule.triggered"
+ RuntimeWebhookEventEventConnectionAttached RuntimeWebhookEventEvent = "connection.attached"
+ RuntimeWebhookEventEventConnectionDetached RuntimeWebhookEventEvent = "connection.detached"
+ RuntimeWebhookEventEventWebhookTest RuntimeWebhookEventEvent = "webhook.test"
+)
+
+func (r RuntimeWebhookEventEvent) IsKnown() bool {
switch r {
- case RuntimeWebhookEventTypeAgentCreated, RuntimeWebhookEventTypeAgentUpdated, RuntimeWebhookEventTypeAgentDeleted, RuntimeWebhookEventTypeThreadCreated, RuntimeWebhookEventTypeThreadStatusChanged, RuntimeWebhookEventTypeThreadCompleted, RuntimeWebhookEventTypeThreadFailed, RuntimeWebhookEventTypeTurnCreated, RuntimeWebhookEventTypeTurnCompleted, RuntimeWebhookEventTypeTurnFailed, RuntimeWebhookEventTypeMessageCreated, RuntimeWebhookEventTypeApprovalRequested, RuntimeWebhookEventTypeApprovalResolved, RuntimeWebhookEventTypeApprovalGranted, RuntimeWebhookEventTypeScheduleCreated, RuntimeWebhookEventTypeScheduleDeleted, RuntimeWebhookEventTypeScheduleTriggered, RuntimeWebhookEventTypeConnectionAttached, RuntimeWebhookEventTypeConnectionDetached, RuntimeWebhookEventTypeWebhookTest:
+ case RuntimeWebhookEventEventAgentCreated, RuntimeWebhookEventEventAgentUpdated, RuntimeWebhookEventEventAgentDeleted, RuntimeWebhookEventEventThreadCreated, RuntimeWebhookEventEventThreadStatusChanged, RuntimeWebhookEventEventThreadCompleted, RuntimeWebhookEventEventThreadFailed, RuntimeWebhookEventEventTurnCreated, RuntimeWebhookEventEventTurnCompleted, RuntimeWebhookEventEventTurnFailed, RuntimeWebhookEventEventMessageCreated, RuntimeWebhookEventEventApprovalRequested, RuntimeWebhookEventEventApprovalResolved, RuntimeWebhookEventEventApprovalGranted, RuntimeWebhookEventEventScheduleCreated, RuntimeWebhookEventEventScheduleDeleted, RuntimeWebhookEventEventScheduleTriggered, RuntimeWebhookEventEventConnectionAttached, RuntimeWebhookEventEventConnectionDetached, RuntimeWebhookEventEventWebhookTest:
return true
}
return false
diff --git a/log.go b/log.go
deleted file mode 100644
index 233e4c8..0000000
--- a/log.go
+++ /dev/null
@@ -1,179 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
- "github.com/matrices/cerca-go/packages/pagination"
-)
-
-// LogService contains methods and other services that help with interacting with
-// the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewLogService] method instead.
-type LogService struct {
- Options []option.RequestOption
-}
-
-// NewLogService generates a new service that applies the given options to each
-// request. These options are applied after the parent client's options (if there
-// is one), and before any request-specific options.
-func NewLogService(opts ...option.RequestOption) (r *LogService) {
- r = &LogService{}
- r.Options = opts
- return
-}
-
-func (r *LogService) ListForAgent(ctx context.Context, agentID string, query LogListForAgentParams, opts ...option.RequestOption) (res *pagination.LogsCursorPage[ThreadLog], err error) {
- var raw *http.Response
- opts = slices.Concat(r.Options, opts)
- opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
- if agentID == "" {
- err = errors.New("missing required agentId parameter")
- return nil, err
- }
- path := fmt.Sprintf("agents/%s/logs", agentID)
- cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
- if err != nil {
- return nil, err
- }
- err = cfg.Execute()
- if err != nil {
- return nil, err
- }
- res.SetPageConfig(cfg, raw)
- return res, nil
-}
-
-func (r *LogService) ListForAgentAutoPaging(ctx context.Context, agentID string, query LogListForAgentParams, opts ...option.RequestOption) *pagination.LogsCursorPageAutoPager[ThreadLog] {
- return pagination.NewLogsCursorPageAutoPager(r.ListForAgent(ctx, agentID, query, opts...))
-}
-
-func (r *LogService) ListForThread(ctx context.Context, agentID string, threadID string, query LogListForThreadParams, opts ...option.RequestOption) (res *pagination.LogsCursorPage[ThreadLog], err error) {
- var raw *http.Response
- opts = slices.Concat(r.Options, opts)
- opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
- if agentID == "" {
- err = errors.New("missing required agentId parameter")
- return nil, err
- }
- if threadID == "" {
- err = errors.New("missing required threadId parameter")
- return nil, err
- }
- path := fmt.Sprintf("agents/%s/threads/%s/logs", agentID, threadID)
- cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
- if err != nil {
- return nil, err
- }
- err = cfg.Execute()
- if err != nil {
- return nil, err
- }
- res.SetPageConfig(cfg, raw)
- return res, nil
-}
-
-func (r *LogService) ListForThreadAutoPaging(ctx context.Context, agentID string, threadID string, query LogListForThreadParams, opts ...option.RequestOption) *pagination.LogsCursorPageAutoPager[ThreadLog] {
- return pagination.NewLogsCursorPageAutoPager(r.ListForThread(ctx, agentID, threadID, query, opts...))
-}
-
-type ThreadLog struct {
- ID string `json:"id" api:"required"`
- Activity string `json:"activity" api:"required,nullable"`
- CreatedAt string `json:"createdAt" api:"required"`
- InputTokens float64 `json:"inputTokens" api:"required"`
- MessageCount float64 `json:"messageCount" api:"required"`
- NextStep string `json:"nextStep" api:"required,nullable"`
- OutputTokens float64 `json:"outputTokens" api:"required"`
- Status ThreadLogStatus `json:"status" api:"required"`
- ThreadID string `json:"threadId" api:"required"`
- TurnCompletedAt string `json:"turnCompletedAt" api:"required"`
- TurnSeq float64 `json:"turnSeq" api:"required"`
- JSON threadLogJSON `json:"-"`
-}
-
-// threadLogJSON contains the JSON metadata for the struct [ThreadLog]
-type threadLogJSON struct {
- ID apijson.Field
- Activity apijson.Field
- CreatedAt apijson.Field
- InputTokens apijson.Field
- MessageCount apijson.Field
- NextStep apijson.Field
- OutputTokens apijson.Field
- Status apijson.Field
- ThreadID apijson.Field
- TurnCompletedAt apijson.Field
- TurnSeq apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ThreadLog) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r threadLogJSON) RawJSON() string {
- return r.raw
-}
-
-type ThreadLogStatus string
-
-const (
- ThreadLogStatusCompleted ThreadLogStatus = "completed"
- ThreadLogStatusFailed ThreadLogStatus = "failed"
-)
-
-func (r ThreadLogStatus) IsKnown() bool {
- switch r {
- case ThreadLogStatusCompleted, ThreadLogStatusFailed:
- return true
- }
- return false
-}
-
-type LogListForAgentParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [LogListForAgentParams]'s query parameters as `url.Values`.
-func (r LogListForAgentParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
-
-type LogListForThreadParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [LogListForThreadParams]'s query parameters as `url.Values`.
-func (r LogListForThreadParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/log_test.go b/log_test.go
deleted file mode 100644
index ac79ff5..0000000
--- a/log_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestLogListForAgentWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Logs.ListForAgent(
- context.TODO(),
- "agent_abc123",
- cercago.LogListForAgentParams{
- Cursor: cercago.F("cursor_abc123"),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestLogListForThreadWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Logs.ListForThread(
- context.TODO(),
- "agent_abc123",
- "thread_abc123",
- cercago.LogListForThreadParams{
- Cursor: cercago.F("cursor_abc123"),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/model.go b/model.go
index 9d3a4ea..d461c4a 100644
--- a/model.go
+++ b/model.go
@@ -31,6 +31,7 @@ func NewModelService(opts ...option.RequestOption) (r *ModelService) {
return
}
+// Models
func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (res *ModelListResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "models"
diff --git a/oauth.go b/oauth.go
index 0c32cc4..971bd38 100644
--- a/oauth.go
+++ b/oauth.go
@@ -34,6 +34,7 @@ func NewOAuthService(opts ...option.RequestOption) (r *OAuthService) {
return
}
+// Connect
func (r *OAuthService) Connect(ctx context.Context, provider string, body OAuthConnectParams, opts ...option.RequestOption) (res *OAuthConnectResponse, err error) {
opts = slices.Concat(r.Options, opts)
if provider == "" {
@@ -77,10 +78,11 @@ func (r oauthConnectResponseJSON) RawJSON() string {
}
type OAuthConnectParams struct {
+ // Public owner for a reusable connection. Organization owners use the
+ // authenticated organization; fleet owners add a fleetId.
+ Owner param.Field[ConnectionOwnerUnionParam] `json:"owner" api:"required"`
// HTTP(S) origin that receives the OAuth completion message.
ReturnOrigin param.Field[string] `json:"returnOrigin" api:"required"`
- // Credential connection scope to attach the OAuth account to.
- Scope param.Field[string] `json:"scope" api:"required"`
// Provider-specific OAuth scopes. Empty entries are ignored after trimming.
Scopes param.Field[[]string] `json:"scopes"`
}
diff --git a/oauth_test.go b/oauth_test.go
index 59789fb..d0ec837 100644
--- a/oauth_test.go
+++ b/oauth_test.go
@@ -29,8 +29,10 @@ func TestOAuthConnectWithOptionalParams(t *testing.T) {
context.TODO(),
"google",
cercago.OAuthConnectParams{
+ Owner: cercago.F[cercago.ConnectionOwnerUnionParam](cercago.ConnectionOwnerOrganizationConnectionOwnerParam{
+ Type: cercago.F(cercago.ConnectionOwnerOrganizationConnectionOwnerTypeOrganization),
+ }),
ReturnOrigin: cercago.F("https://app.example.com"),
- Scope: cercago.F("env:org_abc123:fleet_abc123"),
Scopes: cercago.F([]string{"email", "profile"}),
},
)
diff --git a/packages/pagination/pagination.go b/packages/pagination/pagination.go
index 9230200..e8bc7ef 100644
--- a/packages/pagination/pagination.go
+++ b/packages/pagination/pagination.go
@@ -120,18 +120,18 @@ func (r *AgentsCursorPageAutoPager[T]) Index() int {
return r.run
}
-type ApprovalsCursorPage[T any] struct {
- Approvals []T `json:"approvals"`
- Cursor string `json:"cursor" api:"nullable"`
- HasMore bool `json:"hasMore"`
- JSON approvalsCursorPageJSON `json:"-"`
+type ApprovalRequestsCursorPage[T any] struct {
+ Approvals []T `json:"approvals"`
+ Cursor string `json:"cursor" api:"nullable"`
+ HasMore bool `json:"hasMore"`
+ JSON approvalRequestsCursorPageJSON `json:"-"`
cfg *requestconfig.RequestConfig
res *http.Response
}
-// approvalsCursorPageJSON contains the JSON metadata for the struct
-// [ApprovalsCursorPage[T]]
-type approvalsCursorPageJSON struct {
+// approvalRequestsCursorPageJSON contains the JSON metadata for the struct
+// [ApprovalRequestsCursorPage[T]]
+type approvalRequestsCursorPageJSON struct {
Approvals apijson.Field
Cursor apijson.Field
HasMore apijson.Field
@@ -139,18 +139,18 @@ type approvalsCursorPageJSON struct {
ExtraFields map[string]apijson.Field
}
-func (r *ApprovalsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+func (r *ApprovalRequestsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r approvalsCursorPageJSON) RawJSON() string {
+func (r approvalRequestsCursorPageJSON) RawJSON() string {
return r.raw
}
// GetNextPage returns the next page as defined by this pagination style. When
// there is no next page, this function will return a 'nil' for the page value, but
// will not return an error
-func (r *ApprovalsCursorPage[T]) GetNextPage() (res *ApprovalsCursorPage[T], err error) {
+func (r *ApprovalRequestsCursorPage[T]) GetNextPage() (res *ApprovalRequestsCursorPage[T], err error) {
if len(r.Approvals) == 0 {
return nil, nil
}
@@ -178,30 +178,30 @@ func (r *ApprovalsCursorPage[T]) GetNextPage() (res *ApprovalsCursorPage[T], err
return res, nil
}
-func (r *ApprovalsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+func (r *ApprovalRequestsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
if r == nil {
- r = &ApprovalsCursorPage[T]{}
+ r = &ApprovalRequestsCursorPage[T]{}
}
r.cfg = cfg
r.res = res
}
-type ApprovalsCursorPageAutoPager[T any] struct {
- page *ApprovalsCursorPage[T]
+type ApprovalRequestsCursorPageAutoPager[T any] struct {
+ page *ApprovalRequestsCursorPage[T]
cur T
idx int
run int
err error
}
-func NewApprovalsCursorPageAutoPager[T any](page *ApprovalsCursorPage[T], err error) *ApprovalsCursorPageAutoPager[T] {
- return &ApprovalsCursorPageAutoPager[T]{
+func NewApprovalRequestsCursorPageAutoPager[T any](page *ApprovalRequestsCursorPage[T], err error) *ApprovalRequestsCursorPageAutoPager[T] {
+ return &ApprovalRequestsCursorPageAutoPager[T]{
page: page,
err: err,
}
}
-func (r *ApprovalsCursorPageAutoPager[T]) Next() bool {
+func (r *ApprovalRequestsCursorPageAutoPager[T]) Next() bool {
if r.page == nil || len(r.page.Approvals) == 0 {
return false
}
@@ -218,15 +218,15 @@ func (r *ApprovalsCursorPageAutoPager[T]) Next() bool {
return true
}
-func (r *ApprovalsCursorPageAutoPager[T]) Current() T {
+func (r *ApprovalRequestsCursorPageAutoPager[T]) Current() T {
return r.cur
}
-func (r *ApprovalsCursorPageAutoPager[T]) Err() error {
+func (r *ApprovalRequestsCursorPageAutoPager[T]) Err() error {
return r.err
}
-func (r *ApprovalsCursorPageAutoPager[T]) Index() int {
+func (r *ApprovalRequestsCursorPageAutoPager[T]) Index() int {
return r.run
}
@@ -780,115 +780,6 @@ func (r *GrantsCursorPageAutoPager[T]) Index() int {
return r.run
}
-type LogsCursorPage[T any] struct {
- Logs []T `json:"logs"`
- Cursor string `json:"cursor" api:"nullable"`
- HasMore bool `json:"hasMore"`
- JSON logsCursorPageJSON `json:"-"`
- cfg *requestconfig.RequestConfig
- res *http.Response
-}
-
-// logsCursorPageJSON contains the JSON metadata for the struct [LogsCursorPage[T]]
-type logsCursorPageJSON struct {
- Logs apijson.Field
- Cursor apijson.Field
- HasMore apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *LogsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r logsCursorPageJSON) RawJSON() string {
- return r.raw
-}
-
-// GetNextPage returns the next page as defined by this pagination style. When
-// there is no next page, this function will return a 'nil' for the page value, but
-// will not return an error
-func (r *LogsCursorPage[T]) GetNextPage() (res *LogsCursorPage[T], err error) {
- if len(r.Logs) == 0 {
- return nil, nil
- }
-
- if !r.JSON.HasMore.IsMissing() && r.HasMore == false {
- return nil, nil
- }
- next := r.Cursor
- if len(next) == 0 {
- return nil, nil
- }
- cfg := r.cfg.Clone(r.cfg.Context)
- err = cfg.Apply(option.WithQuery("cursor", next))
- if err != nil {
- return nil, err
- }
- var raw *http.Response
- cfg.ResponseInto = &raw
- cfg.ResponseBodyInto = &res
- err = cfg.Execute()
- if err != nil {
- return nil, err
- }
- res.SetPageConfig(cfg, raw)
- return res, nil
-}
-
-func (r *LogsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
- if r == nil {
- r = &LogsCursorPage[T]{}
- }
- r.cfg = cfg
- r.res = res
-}
-
-type LogsCursorPageAutoPager[T any] struct {
- page *LogsCursorPage[T]
- cur T
- idx int
- run int
- err error
-}
-
-func NewLogsCursorPageAutoPager[T any](page *LogsCursorPage[T], err error) *LogsCursorPageAutoPager[T] {
- return &LogsCursorPageAutoPager[T]{
- page: page,
- err: err,
- }
-}
-
-func (r *LogsCursorPageAutoPager[T]) Next() bool {
- if r.page == nil || len(r.page.Logs) == 0 {
- return false
- }
- if r.idx >= len(r.page.Logs) {
- r.idx = 0
- r.page, r.err = r.page.GetNextPage()
- if r.err != nil || r.page == nil || len(r.page.Logs) == 0 {
- return false
- }
- }
- r.cur = r.page.Logs[r.idx]
- r.run += 1
- r.idx += 1
- return true
-}
-
-func (r *LogsCursorPageAutoPager[T]) Current() T {
- return r.cur
-}
-
-func (r *LogsCursorPageAutoPager[T]) Err() error {
- return r.err
-}
-
-func (r *LogsCursorPageAutoPager[T]) Index() int {
- return r.run
-}
-
type ResultsCursorPage[T any] struct {
Results []T `json:"results"`
Cursor string `json:"cursor" api:"nullable"`
diff --git a/sandbox.go b/sandbox.go
index 460b0e5..7792b16 100644
--- a/sandbox.go
+++ b/sandbox.go
@@ -34,6 +34,7 @@ func NewSandboxService(opts ...option.RequestOption) (r *SandboxService) {
return
}
+// Exec
func (r *SandboxService) Exec(ctx context.Context, agentID string, body SandboxExecParams, opts ...option.RequestOption) (res *ExecResult, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -45,6 +46,7 @@ func (r *SandboxService) Exec(ctx context.Context, agentID string, body SandboxE
return res, err
}
+// Read
func (r *SandboxService) Read(ctx context.Context, agentID string, body SandboxReadParams, opts ...option.RequestOption) (res *ReadResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -56,6 +58,7 @@ func (r *SandboxService) Read(ctx context.Context, agentID string, body SandboxR
return res, err
}
+// Write
func (r *SandboxService) Write(ctx context.Context, agentID string, body SandboxWriteParams, opts ...option.RequestOption) (res *SandboxWriteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/schedule.go b/schedule.go
index 4801135..404a4df 100644
--- a/schedule.go
+++ b/schedule.go
@@ -36,7 +36,8 @@ func NewScheduleService(opts ...option.RequestOption) (r *ScheduleService) {
return
}
-func (r *ScheduleService) New(ctx context.Context, agentID string, body ScheduleNewParams, opts ...option.RequestOption) (res *ScheduledThread, err error) {
+// Schedules
+func (r *ScheduleService) New(ctx context.Context, agentID string, body ScheduleNewParams, opts ...option.RequestOption) (res *Schedule, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
err = errors.New("missing required agentId parameter")
@@ -47,7 +48,8 @@ func (r *ScheduleService) New(ctx context.Context, agentID string, body Schedule
return res, err
}
-func (r *ScheduleService) Update(ctx context.Context, agentID string, scheduleID string, body ScheduleUpdateParams, opts ...option.RequestOption) (res *ScheduledThread, err error) {
+// Schedule
+func (r *ScheduleService) Update(ctx context.Context, agentID string, scheduleID string, body ScheduleUpdateParams, opts ...option.RequestOption) (res *Schedule, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
err = errors.New("missing required agentId parameter")
@@ -62,6 +64,7 @@ func (r *ScheduleService) Update(ctx context.Context, agentID string, scheduleID
return res, err
}
+// Schedules
func (r *ScheduleService) List(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ScheduleListResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -73,6 +76,7 @@ func (r *ScheduleService) List(ctx context.Context, agentID string, opts ...opti
return res, err
}
+// Schedule
func (r *ScheduleService) Delete(ctx context.Context, agentID string, scheduleID string, opts ...option.RequestOption) (res *ScheduleDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -88,6 +92,7 @@ func (r *ScheduleService) Delete(ctx context.Context, agentID string, scheduleID
return res, err
}
+// Trigger
func (r *ScheduleService) Trigger(ctx context.Context, agentID string, scheduleID string, opts ...option.RequestOption) (res *ScheduleTriggerResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -103,31 +108,33 @@ func (r *ScheduleService) Trigger(ctx context.Context, agentID string, scheduleI
return res, err
}
-type ScheduledThread struct {
- ID string `json:"id" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- Name string `json:"name" api:"required"`
- NextAt string `json:"nextAt" api:"required,nullable"`
- Prompt string `json:"prompt" api:"required"`
- Timezone string `json:"timezone" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Cron string `json:"cron"`
- Instructions string `json:"instructions"`
- Model string `json:"model"`
- RunAt time.Time `json:"runAt" format:"date-time"`
- Tools []shared.ToolSpec `json:"tools"`
- JSON scheduledThreadJSON `json:"-"`
+type Schedule struct {
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ Message string `json:"message" api:"required"`
+ Name string `json:"name" api:"required"`
+ NextAt string `json:"nextAt" api:"required,nullable"`
+ Timezone string `json:"timezone" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Cron string `json:"cron"`
+ Instructions string `json:"instructions"`
+ Model string `json:"model"`
+ RunAt time.Time `json:"runAt" format:"date-time"`
+ // Per-schedule tool subset. Scheduled threads inherit the agent's effective tools
+ // when omitted and can only narrow them when provided.
+ Tools []shared.ToolSpec `json:"tools"`
+ JSON scheduleJSON `json:"-"`
}
-// scheduledThreadJSON contains the JSON metadata for the struct [ScheduledThread]
-type scheduledThreadJSON struct {
+// scheduleJSON contains the JSON metadata for the struct [Schedule]
+type scheduleJSON struct {
ID apijson.Field
CreatedAt apijson.Field
Enabled apijson.Field
+ Message apijson.Field
Name apijson.Field
NextAt apijson.Field
- Prompt apijson.Field
Timezone apijson.Field
UpdatedAt apijson.Field
Cron apijson.Field
@@ -139,16 +146,16 @@ type scheduledThreadJSON struct {
ExtraFields map[string]apijson.Field
}
-func (r *ScheduledThread) UnmarshalJSON(data []byte) (err error) {
+func (r *Schedule) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r scheduledThreadJSON) RawJSON() string {
+func (r scheduleJSON) RawJSON() string {
return r.raw
}
type ScheduleListResponse struct {
- Schedules []ScheduledThread `json:"schedules" api:"required"`
+ Schedules []Schedule `json:"schedules" api:"required"`
JSON scheduleListResponseJSON `json:"-"`
}
@@ -225,14 +232,16 @@ func (r scheduleTriggerResponseJSON) RawJSON() string {
}
type ScheduleNewParams struct {
- Name param.Field[string] `json:"name" api:"required"`
- Prompt param.Field[string] `json:"prompt" api:"required"`
- Cron param.Field[string] `json:"cron"`
- Instructions param.Field[string] `json:"instructions"`
- Model param.Field[string] `json:"model"`
- RunAt param.Field[time.Time] `json:"runAt" format:"date-time"`
- Timezone param.Field[string] `json:"timezone"`
- Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+ Message param.Field[string] `json:"message" api:"required"`
+ Name param.Field[string] `json:"name" api:"required"`
+ Cron param.Field[string] `json:"cron"`
+ Instructions param.Field[string] `json:"instructions"`
+ Model param.Field[string] `json:"model"`
+ RunAt param.Field[time.Time] `json:"runAt" format:"date-time"`
+ Timezone param.Field[string] `json:"timezone"`
+ // Per-schedule tool subset. When the schedule starts a thread, these tools can
+ // only narrow the agent's effective tools.
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
}
func (r ScheduleNewParams) MarshalJSON() (data []byte, err error) {
@@ -240,15 +249,17 @@ func (r ScheduleNewParams) MarshalJSON() (data []byte, err error) {
}
type ScheduleUpdateParams struct {
- Cron param.Field[string] `json:"cron"`
- Enabled param.Field[bool] `json:"enabled"`
- Instructions param.Field[string] `json:"instructions"`
- Model param.Field[string] `json:"model"`
- Name param.Field[string] `json:"name"`
- Prompt param.Field[string] `json:"prompt"`
- RunAt param.Field[time.Time] `json:"runAt" format:"date-time"`
- Timezone param.Field[string] `json:"timezone"`
- Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+ Cron param.Field[string] `json:"cron"`
+ Enabled param.Field[bool] `json:"enabled"`
+ Instructions param.Field[string] `json:"instructions"`
+ Message param.Field[string] `json:"message"`
+ Model param.Field[string] `json:"model"`
+ Name param.Field[string] `json:"name"`
+ RunAt param.Field[time.Time] `json:"runAt" format:"date-time"`
+ Timezone param.Field[string] `json:"timezone"`
+ // Per-schedule tool subset. When updated, these tools can only narrow the agent's
+ // effective tools for future scheduled threads.
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
}
func (r ScheduleUpdateParams) MarshalJSON() (data []byte, err error) {
diff --git a/schedule_test.go b/schedule_test.go
index 7151f15..c5cc915 100644
--- a/schedule_test.go
+++ b/schedule_test.go
@@ -31,8 +31,8 @@ func TestScheduleNewWithOptionalParams(t *testing.T) {
context.TODO(),
"agent_abc123",
cercago.ScheduleNewParams{
+ Message: cercago.F("message"),
Name: cercago.F("name"),
- Prompt: cercago.F("prompt"),
Cron: cercago.F("cron"),
Instructions: cercago.F("instructions"),
Model: cercago.F("model"),
@@ -70,9 +70,9 @@ func TestScheduleUpdateWithOptionalParams(t *testing.T) {
Cron: cercago.F("cron"),
Enabled: cercago.F(true),
Instructions: cercago.F("instructions"),
+ Message: cercago.F("message"),
Model: cercago.F("model"),
Name: cercago.F("name"),
- Prompt: cercago.F("prompt"),
RunAt: cercago.F(time.Now()),
Timezone: cercago.F("timezone"),
Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
diff --git a/thread.go b/thread.go
index cfe8a30..eacf575 100644
--- a/thread.go
+++ b/thread.go
@@ -40,6 +40,7 @@ func NewThreadService(opts ...option.RequestOption) (r *ThreadService) {
return
}
+// Threads
func (r *ThreadService) New(ctx context.Context, agentID string, body ThreadNewParams, opts ...option.RequestOption) (res *Thread, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -51,6 +52,7 @@ func (r *ThreadService) New(ctx context.Context, agentID string, body ThreadNewP
return res, err
}
+// Thread
func (r *ThreadService) Get(ctx context.Context, agentID string, threadID string, query ThreadGetParams, opts ...option.RequestOption) (res *Thread, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -66,6 +68,7 @@ func (r *ThreadService) Get(ctx context.Context, agentID string, threadID string
return res, err
}
+// Threads
func (r *ThreadService) List(ctx context.Context, agentID string, query ThreadListParams, opts ...option.RequestOption) (res *pagination.ThreadsCursorPage[ThreadSummary], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -87,6 +90,7 @@ func (r *ThreadService) List(ctx context.Context, agentID string, query ThreadLi
return res, nil
}
+// Threads
func (r *ThreadService) ListAutoPaging(ctx context.Context, agentID string, query ThreadListParams, opts ...option.RequestOption) *pagination.ThreadsCursorPageAutoPager[ThreadSummary] {
return pagination.NewThreadsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
}
@@ -142,6 +146,7 @@ func (r *ThreadService) Compact(ctx context.Context, agentID string, threadID st
return res, err
}
+// Turns
func (r *ThreadService) StartTurn(ctx context.Context, agentID string, threadID string, body ThreadStartTurnParams, opts ...option.RequestOption) (res *Turn, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -198,49 +203,345 @@ func (r compiledContextJSON) RawJSON() string {
return r.raw
}
-type ContentBlock map[string]interface{}
+// Message content block. The `type` field distinguishes text, tool use, tool
+// result, server tool use, and web search result blocks.
+type ContentBlock struct {
+ Type ContentBlockType `json:"type" api:"required"`
+ ID string `json:"id"`
+ // This field can have the runtime type of [string], [interface{}].
+ Content interface{} `json:"content"`
+ DeniedByUser bool `json:"deniedByUser"`
+ // This field can have the runtime type of [interface{}].
+ Input interface{} `json:"input"`
+ IsError bool `json:"isError"`
+ Name shared.ToolName `json:"name"`
+ // This field can have the runtime type of [map[string]map[string]string].
+ ProviderMetadata interface{} `json:"providerMetadata"`
+ Text string `json:"text"`
+ ToolUseID string `json:"toolUseId"`
+ JSON contentBlockJSON `json:"-"`
+ union ContentBlockUnion
+}
+
+// contentBlockJSON contains the JSON metadata for the struct [ContentBlock]
+type contentBlockJSON struct {
+ Type apijson.Field
+ ID apijson.Field
+ Content apijson.Field
+ DeniedByUser apijson.Field
+ Input apijson.Field
+ IsError apijson.Field
+ Name apijson.Field
+ ProviderMetadata apijson.Field
+ Text apijson.Field
+ ToolUseID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r contentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *ContentBlock) UnmarshalJSON(data []byte) (err error) {
+ *r = ContentBlock{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [ContentBlockUnion] interface which you can cast to the
+// specific types for more type safety.
+//
+// Possible runtime types of the union are [ContentBlockTextContentBlock],
+// [ContentBlockToolUseContentBlock], [ContentBlockToolResultContentBlock],
+// [ContentBlockServerToolUseContentBlock],
+// [ContentBlockWebSearchToolResultContentBlock].
+func (r ContentBlock) AsUnion() ContentBlockUnion {
+ return r.union
+}
+
+// Message content block. The `type` field distinguishes text, tool use, tool
+// result, server tool use, and web search result blocks.
+//
+// Union satisfied by [ContentBlockTextContentBlock],
+// [ContentBlockToolUseContentBlock], [ContentBlockToolResultContentBlock],
+// [ContentBlockServerToolUseContentBlock] or
+// [ContentBlockWebSearchToolResultContentBlock].
+type ContentBlockUnion interface {
+ implementsContentBlock()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ContentBlockUnion)(nil)).Elem(),
+ "type",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ContentBlockTextContentBlock{}),
+ DiscriminatorValue: "text",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ContentBlockToolUseContentBlock{}),
+ DiscriminatorValue: "tool_use",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ContentBlockToolResultContentBlock{}),
+ DiscriminatorValue: "tool_result",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ContentBlockServerToolUseContentBlock{}),
+ DiscriminatorValue: "server_tool_use",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ContentBlockWebSearchToolResultContentBlock{}),
+ DiscriminatorValue: "web_search_tool_result",
+ },
+ )
+}
-type ContextWindow struct {
- Compacted bool `json:"compacted" api:"required"`
- CompactionThroughSeq float64 `json:"compactionThroughSeq" api:"required,nullable"`
- ContextWindowTokens float64 `json:"contextWindowTokens" api:"required"`
- EstimationMethod ContextWindowEstimationMethod `json:"estimationMethod" api:"required"`
- LlmEstimatedTokens float64 `json:"llmEstimatedTokens" api:"required"`
- Model string `json:"model" api:"required"`
- RawEstimatedTokens float64 `json:"rawEstimatedTokens" api:"required"`
- JSON contextWindowJSON `json:"-"`
+type ContentBlockTextContentBlock struct {
+ Text string `json:"text" api:"required"`
+ Type ContentBlockTextContentBlockType `json:"type" api:"required"`
+ ProviderMetadata map[string]map[string]string `json:"providerMetadata"`
+ JSON contentBlockTextContentBlockJSON `json:"-"`
}
-// contextWindowJSON contains the JSON metadata for the struct [ContextWindow]
-type contextWindowJSON struct {
- Compacted apijson.Field
- CompactionThroughSeq apijson.Field
- ContextWindowTokens apijson.Field
- EstimationMethod apijson.Field
- LlmEstimatedTokens apijson.Field
- Model apijson.Field
- RawEstimatedTokens apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
+// contentBlockTextContentBlockJSON contains the JSON metadata for the struct
+// [ContentBlockTextContentBlock]
+type contentBlockTextContentBlockJSON struct {
+ Text apijson.Field
+ Type apijson.Field
+ ProviderMetadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
}
-func (r *ContextWindow) UnmarshalJSON(data []byte) (err error) {
+func (r *ContentBlockTextContentBlock) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r contextWindowJSON) RawJSON() string {
+func (r contentBlockTextContentBlockJSON) RawJSON() string {
return r.raw
}
-type ContextWindowEstimationMethod string
+func (r ContentBlockTextContentBlock) implementsContentBlock() {}
+
+type ContentBlockTextContentBlockType string
+
+const (
+ ContentBlockTextContentBlockTypeText ContentBlockTextContentBlockType = "text"
+)
+
+func (r ContentBlockTextContentBlockType) IsKnown() bool {
+ switch r {
+ case ContentBlockTextContentBlockTypeText:
+ return true
+ }
+ return false
+}
+
+type ContentBlockToolUseContentBlock struct {
+ ID string `json:"id" api:"required"`
+ // Any JSON value. Generated SDKs may expose this value boundary as unknown or Any.
+ Input interface{} `json:"input" api:"required"`
+ Name shared.ToolName `json:"name" api:"required"`
+ Type ContentBlockToolUseContentBlockType `json:"type" api:"required"`
+ ProviderMetadata map[string]map[string]string `json:"providerMetadata"`
+ JSON contentBlockToolUseContentBlockJSON `json:"-"`
+}
+
+// contentBlockToolUseContentBlockJSON contains the JSON metadata for the struct
+// [ContentBlockToolUseContentBlock]
+type contentBlockToolUseContentBlockJSON struct {
+ ID apijson.Field
+ Input apijson.Field
+ Name apijson.Field
+ Type apijson.Field
+ ProviderMetadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ContentBlockToolUseContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r contentBlockToolUseContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ContentBlockToolUseContentBlock) implementsContentBlock() {}
+
+type ContentBlockToolUseContentBlockType string
+
+const (
+ ContentBlockToolUseContentBlockTypeToolUse ContentBlockToolUseContentBlockType = "tool_use"
+)
+
+func (r ContentBlockToolUseContentBlockType) IsKnown() bool {
+ switch r {
+ case ContentBlockToolUseContentBlockTypeToolUse:
+ return true
+ }
+ return false
+}
+
+type ContentBlockToolResultContentBlock struct {
+ Content string `json:"content" api:"required"`
+ IsError bool `json:"isError" api:"required"`
+ ToolUseID string `json:"toolUseId" api:"required"`
+ Type ContentBlockToolResultContentBlockType `json:"type" api:"required"`
+ DeniedByUser bool `json:"deniedByUser"`
+ ProviderMetadata map[string]map[string]string `json:"providerMetadata"`
+ JSON contentBlockToolResultContentBlockJSON `json:"-"`
+}
+
+// contentBlockToolResultContentBlockJSON contains the JSON metadata for the struct
+// [ContentBlockToolResultContentBlock]
+type contentBlockToolResultContentBlockJSON struct {
+ Content apijson.Field
+ IsError apijson.Field
+ ToolUseID apijson.Field
+ Type apijson.Field
+ DeniedByUser apijson.Field
+ ProviderMetadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ContentBlockToolResultContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r contentBlockToolResultContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ContentBlockToolResultContentBlock) implementsContentBlock() {}
+
+type ContentBlockToolResultContentBlockType string
+
+const (
+ ContentBlockToolResultContentBlockTypeToolResult ContentBlockToolResultContentBlockType = "tool_result"
+)
+
+func (r ContentBlockToolResultContentBlockType) IsKnown() bool {
+ switch r {
+ case ContentBlockToolResultContentBlockTypeToolResult:
+ return true
+ }
+ return false
+}
+
+type ContentBlockServerToolUseContentBlock struct {
+ ID string `json:"id" api:"required"`
+ // Any JSON value. Generated SDKs may expose this value boundary as unknown or Any.
+ Input interface{} `json:"input" api:"required"`
+ Name string `json:"name" api:"required"`
+ Type ContentBlockServerToolUseContentBlockType `json:"type" api:"required"`
+ ProviderMetadata map[string]map[string]string `json:"providerMetadata"`
+ JSON contentBlockServerToolUseContentBlockJSON `json:"-"`
+}
+
+// contentBlockServerToolUseContentBlockJSON contains the JSON metadata for the
+// struct [ContentBlockServerToolUseContentBlock]
+type contentBlockServerToolUseContentBlockJSON struct {
+ ID apijson.Field
+ Input apijson.Field
+ Name apijson.Field
+ Type apijson.Field
+ ProviderMetadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ContentBlockServerToolUseContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r contentBlockServerToolUseContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ContentBlockServerToolUseContentBlock) implementsContentBlock() {}
+
+type ContentBlockServerToolUseContentBlockType string
const (
- ContextWindowEstimationMethodHeuristicRequestV1 ContextWindowEstimationMethod = "heuristic_request_v1"
+ ContentBlockServerToolUseContentBlockTypeServerToolUse ContentBlockServerToolUseContentBlockType = "server_tool_use"
)
-func (r ContextWindowEstimationMethod) IsKnown() bool {
+func (r ContentBlockServerToolUseContentBlockType) IsKnown() bool {
switch r {
- case ContextWindowEstimationMethodHeuristicRequestV1:
+ case ContentBlockServerToolUseContentBlockTypeServerToolUse:
+ return true
+ }
+ return false
+}
+
+type ContentBlockWebSearchToolResultContentBlock struct {
+ // Web search result payload. The runtime returns either an array of web search
+ // results or an error object.
+ Content interface{} `json:"content" api:"required"`
+ ToolUseID string `json:"toolUseId" api:"required"`
+ Type ContentBlockWebSearchToolResultContentBlockType `json:"type" api:"required"`
+ JSON contentBlockWebSearchToolResultContentBlockJSON `json:"-"`
+}
+
+// contentBlockWebSearchToolResultContentBlockJSON contains the JSON metadata for
+// the struct [ContentBlockWebSearchToolResultContentBlock]
+type contentBlockWebSearchToolResultContentBlockJSON struct {
+ Content apijson.Field
+ ToolUseID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ContentBlockWebSearchToolResultContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r contentBlockWebSearchToolResultContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ContentBlockWebSearchToolResultContentBlock) implementsContentBlock() {}
+
+type ContentBlockWebSearchToolResultContentBlockType string
+
+const (
+ ContentBlockWebSearchToolResultContentBlockTypeWebSearchToolResult ContentBlockWebSearchToolResultContentBlockType = "web_search_tool_result"
+)
+
+func (r ContentBlockWebSearchToolResultContentBlockType) IsKnown() bool {
+ switch r {
+ case ContentBlockWebSearchToolResultContentBlockTypeWebSearchToolResult:
+ return true
+ }
+ return false
+}
+
+type ContentBlockType string
+
+const (
+ ContentBlockTypeText ContentBlockType = "text"
+ ContentBlockTypeToolUse ContentBlockType = "tool_use"
+ ContentBlockTypeToolResult ContentBlockType = "tool_result"
+ ContentBlockTypeServerToolUse ContentBlockType = "server_tool_use"
+ ContentBlockTypeWebSearchToolResult ContentBlockType = "web_search_tool_result"
+)
+
+func (r ContentBlockType) IsKnown() bool {
+ switch r {
+ case ContentBlockTypeText, ContentBlockTypeToolUse, ContentBlockTypeToolResult, ContentBlockTypeServerToolUse, ContentBlockTypeWebSearchToolResult:
return true
}
return false
@@ -287,29 +588,6 @@ func (r MessageRole) IsKnown() bool {
return false
}
-type PendingSubThread struct {
- SubThreadID string `json:"subThreadId" api:"required"`
- ToolUseID string `json:"toolUseId" api:"required"`
- JSON pendingSubThreadJSON `json:"-"`
-}
-
-// pendingSubThreadJSON contains the JSON metadata for the struct
-// [PendingSubThread]
-type pendingSubThreadJSON struct {
- SubThreadID apijson.Field
- ToolUseID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *PendingSubThread) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r pendingSubThreadJSON) RawJSON() string {
- return r.raw
-}
-
// `idle` threads can accept a new turn or be closed. `running` threads have an
// active turn. `awaiting` threads are paused on external input such as approvals.
// `closed` threads are terminal.
@@ -372,39 +650,96 @@ func (r SteerResultStatus) IsKnown() bool {
return false
}
+type SubThreadSummary struct {
+ ID string `json:"id" api:"required"`
+ CompletedAt string `json:"completedAt" api:"required,nullable"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ MessageCount float64 `json:"messageCount" api:"required"`
+ Model string `json:"model" api:"required"`
+ ParentThreadID string `json:"parentThreadId" api:"required,nullable"`
+ Result string `json:"result" api:"required,nullable"`
+ ScheduleID string `json:"scheduleId" api:"required,nullable"`
+ ScheduleSeq float64 `json:"scheduleSeq" api:"required,nullable"`
+ // `pending` means the parent thread is still waiting on this sub-thread. Other
+ // values are the child thread lifecycle state.
+ State SubThreadSummaryState `json:"state" api:"required"`
+ StepCount float64 `json:"stepCount" api:"required"`
+ ToolUseID string `json:"toolUseId" api:"required,nullable"`
+ JSON subThreadSummaryJSON `json:"-"`
+}
+
+// subThreadSummaryJSON contains the JSON metadata for the struct
+// [SubThreadSummary]
+type subThreadSummaryJSON struct {
+ ID apijson.Field
+ CompletedAt apijson.Field
+ CreatedAt apijson.Field
+ MessageCount apijson.Field
+ Model apijson.Field
+ ParentThreadID apijson.Field
+ Result apijson.Field
+ ScheduleID apijson.Field
+ ScheduleSeq apijson.Field
+ State apijson.Field
+ StepCount apijson.Field
+ ToolUseID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SubThreadSummary) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r subThreadSummaryJSON) RawJSON() string {
+ return r.raw
+}
+
+// `pending` means the parent thread is still waiting on this sub-thread. Other
+// values are the child thread lifecycle state.
+type SubThreadSummaryState string
+
+const (
+ SubThreadSummaryStatePending SubThreadSummaryState = "pending"
+ SubThreadSummaryStateIdle SubThreadSummaryState = "idle"
+ SubThreadSummaryStateRunning SubThreadSummaryState = "running"
+ SubThreadSummaryStateAwaiting SubThreadSummaryState = "awaiting"
+ SubThreadSummaryStateClosed SubThreadSummaryState = "closed"
+)
+
+func (r SubThreadSummaryState) IsKnown() bool {
+ switch r {
+ case SubThreadSummaryStatePending, SubThreadSummaryStateIdle, SubThreadSummaryStateRunning, SubThreadSummaryStateAwaiting, SubThreadSummaryStateClosed:
+ return true
+ }
+ return false
+}
+
type Thread struct {
- ID string `json:"id" api:"required"`
- AgentID string `json:"agentId" api:"required"`
- CompactionSummary string `json:"compactionSummary" api:"required,nullable"`
- CompactionThroughSeq float64 `json:"compactionThroughSeq" api:"required,nullable"`
- CompiledContext CompiledContext `json:"compiledContext" api:"required,nullable"`
- CompletedAt string `json:"completedAt" api:"required,nullable"`
- ComposedSystemPrompt string `json:"composedSystemPrompt" api:"required,nullable"`
- ContextWindow ContextWindow `json:"contextWindow" api:"required,nullable"`
- CreatedAt string `json:"createdAt" api:"required"`
- Depth float64 `json:"depth" api:"required"`
- Error string `json:"error" api:"required,nullable"`
- HasMoreMessages bool `json:"hasMoreMessages" api:"required"`
- Instructions string `json:"instructions" api:"required,nullable"`
- LastTurnStatus ThreadLastTurnStatus `json:"lastTurnStatus" api:"required,nullable"`
- MessageCursor float64 `json:"messageCursor" api:"required,nullable"`
- Messages []Message `json:"messages" api:"required"`
- Model string `json:"model" api:"required"`
- ParentThreadID string `json:"parentThreadId" api:"required,nullable"`
- PendingSubThreads []PendingSubThread `json:"pendingSubThreads" api:"required"`
- Result string `json:"result" api:"required,nullable"`
- ScheduleID string `json:"scheduleId" api:"required,nullable"`
- ScheduleSeq float64 `json:"scheduleSeq" api:"required,nullable"`
+ ID string `json:"id" api:"required"`
+ AgentID string `json:"agentId" api:"required"`
+ CompiledContext CompiledContext `json:"compiledContext" api:"required,nullable"`
+ CompletedAt string `json:"completedAt" api:"required,nullable"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Depth float64 `json:"depth" api:"required"`
+ Error string `json:"error" api:"required,nullable"`
+ Instructions string `json:"instructions" api:"required,nullable"`
+ LastTurnStatus ThreadLastTurnStatus `json:"lastTurnStatus" api:"required,nullable"`
+ Message string `json:"message" api:"required"`
+ Messages []Message `json:"messages" api:"required"`
+ Model string `json:"model" api:"required"`
+ ParentThreadID string `json:"parentThreadId" api:"required,nullable"`
+ Result string `json:"result" api:"required,nullable"`
+ ScheduleID string `json:"scheduleId" api:"required,nullable"`
+ ScheduleSeq float64 `json:"scheduleSeq" api:"required,nullable"`
// `idle` threads can accept a new turn or be closed. `running` threads have an
// active turn. `awaiting` threads are paused on external input such as approvals.
// `closed` threads are terminal.
Status Status `json:"status" api:"required"`
- SubThreads []ThreadSummary `json:"subThreads" api:"required"`
+ SubThreads []SubThreadSummary `json:"subThreads" api:"required"`
Tools []shared.ToolName `json:"tools" api:"required"`
Turns []Turn `json:"turns" api:"required"`
UpdatedAt string `json:"updatedAt" api:"required"`
- UserMessage string `json:"userMessage" api:"required"`
- ActiveTurnModel string `json:"activeTurnModel" api:"nullable"`
ExternalToolNamespaces ThreadExternalToolNamespacesUnion `json:"externalToolNamespaces"`
JSON threadJSON `json:"-"`
}
@@ -413,23 +748,17 @@ type Thread struct {
type threadJSON struct {
ID apijson.Field
AgentID apijson.Field
- CompactionSummary apijson.Field
- CompactionThroughSeq apijson.Field
CompiledContext apijson.Field
CompletedAt apijson.Field
- ComposedSystemPrompt apijson.Field
- ContextWindow apijson.Field
CreatedAt apijson.Field
Depth apijson.Field
Error apijson.Field
- HasMoreMessages apijson.Field
Instructions apijson.Field
LastTurnStatus apijson.Field
- MessageCursor apijson.Field
+ Message apijson.Field
Messages apijson.Field
Model apijson.Field
ParentThreadID apijson.Field
- PendingSubThreads apijson.Field
Result apijson.Field
ScheduleID apijson.Field
ScheduleSeq apijson.Field
@@ -438,8 +767,6 @@ type threadJSON struct {
Tools apijson.Field
Turns apijson.Field
UpdatedAt apijson.Field
- UserMessage apijson.Field
- ActiveTurnModel apijson.Field
ExternalToolNamespaces apijson.Field
raw string
ExtraFields map[string]apijson.Field
@@ -579,6 +906,7 @@ type Turn struct {
CompletedAt string `json:"completedAt" api:"required,nullable"`
EndMessageSeq float64 `json:"endMessageSeq" api:"required,nullable"`
Error string `json:"error" api:"required,nullable"`
+ Message string `json:"message" api:"required"`
Result string `json:"result" api:"required,nullable"`
Seq float64 `json:"seq" api:"required"`
StartedAt string `json:"startedAt" api:"required"`
@@ -586,7 +914,6 @@ type Turn struct {
Status TurnStatus `json:"status" api:"required"`
ThreadID string `json:"threadId" api:"required"`
TokenUsage TokenUsage `json:"tokenUsage" api:"required,nullable"`
- UserMessage string `json:"userMessage" api:"required"`
JSON turnJSON `json:"-"`
}
@@ -596,6 +923,7 @@ type turnJSON struct {
CompletedAt apijson.Field
EndMessageSeq apijson.Field
Error apijson.Field
+ Message apijson.Field
Result apijson.Field
Seq apijson.Field
StartedAt apijson.Field
@@ -603,7 +931,6 @@ type turnJSON struct {
Status apijson.Field
ThreadID apijson.Field
TokenUsage apijson.Field
- UserMessage apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
@@ -634,11 +961,14 @@ func (r TurnStatus) IsKnown() bool {
type ThreadNewParams struct {
Instructions param.Field[string] `json:"instructions"`
+ Message param.Field[string] `json:"message"`
Model param.Field[string] `json:"model"`
// Deprecated alias for `instructions`; accepted for backwards compatibility.
- SystemPrompt param.Field[string] `json:"systemPrompt"`
- Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
- UserMessage param.Field[string] `json:"userMessage"`
+ SystemPrompt param.Field[string] `json:"systemPrompt"`
+ // Per-thread tool subset. Omit to inherit the agent's full effective tools; pass
+ // [] to run with no configurable tools. Provided entries can only narrow the
+ // agent's effective tools.
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
}
func (r ThreadNewParams) MarshalJSON() (data []byte, err error) {
@@ -646,19 +976,10 @@ func (r ThreadNewParams) MarshalJSON() (data []byte, err error) {
}
type ThreadGetParams struct {
- // Return messages newer than this sequence number. Mutually exclusive with
- // `beforeSeq`.
- AfterSeq param.Field[string] `query:"afterSeq"`
- // Return messages older than this sequence number. Mutually exclusive with
- // `afterSeq`.
- BeforeSeq param.Field[string] `query:"beforeSeq"`
// When true, includes debug-only compiled context fields.
Debug param.Field[ThreadGetParamsDebug] `query:"debug"`
// When true, includes message content in the thread detail.
IncludeMessages param.Field[ThreadGetParamsIncludeMessages] `query:"includeMessages"`
- // Maximum number of messages to include. Set to 0 to return metadata without
- // messages.
- MessageLimit param.Field[string] `query:"messageLimit"`
}
// URLQuery serializes [ThreadGetParams]'s query parameters as `url.Values`.
@@ -722,9 +1043,12 @@ func (r ThreadListParams) URLQuery() (v url.Values) {
}
type ThreadStartTurnParams struct {
- UserMessage param.Field[string] `json:"userMessage" api:"required"`
- Model param.Field[string] `json:"model"`
- Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
+ Message param.Field[string] `json:"message" api:"required"`
+ Model param.Field[string] `json:"model"`
+ // Per-turn tool subset. Omit to inherit the thread's current tools; pass [] to run
+ // this turn with no configurable tools. Provided entries can only narrow the
+ // agent/thread effective tools.
+ Tools param.Field[[]shared.ToolSpecParam] `json:"tools"`
}
func (r ThreadStartTurnParams) MarshalJSON() (data []byte, err error) {
diff --git a/thread_test.go b/thread_test.go
index 0fbd638..3317281 100644
--- a/thread_test.go
+++ b/thread_test.go
@@ -31,10 +31,10 @@ func TestThreadNewWithOptionalParams(t *testing.T) {
"agent_abc123",
cercago.ThreadNewParams{
Instructions: cercago.F("instructions"),
+ Message: cercago.F("message"),
Model: cercago.F("model"),
SystemPrompt: cercago.F("systemPrompt"),
Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
- UserMessage: cercago.F("userMessage"),
},
)
if err != nil {
@@ -63,11 +63,8 @@ func TestThreadGetWithOptionalParams(t *testing.T) {
"agent_abc123",
"thread_abc123",
cercago.ThreadGetParams{
- AfterSeq: cercago.F("42"),
- BeforeSeq: cercago.F("42"),
Debug: cercago.F(cercago.ThreadGetParamsDebugFalse),
IncludeMessages: cercago.F(cercago.ThreadGetParamsIncludeMessagesTrue),
- MessageLimit: cercago.F("50"),
},
)
if err != nil {
@@ -205,9 +202,9 @@ func TestThreadStartTurnWithOptionalParams(t *testing.T) {
"agent_abc123",
"thread_abc123",
cercago.ThreadStartTurnParams{
- UserMessage: cercago.F("userMessage"),
- Model: cercago.F("model"),
- Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
+ Message: cercago.F("message"),
+ Model: cercago.F("model"),
+ Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
},
)
if err != nil {
diff --git a/tool.go b/tool.go
index e5b019c..e9af549 100644
--- a/tool.go
+++ b/tool.go
@@ -7,12 +7,17 @@ import (
"errors"
"fmt"
"net/http"
+ "net/url"
+ "reflect"
"slices"
"github.com/matrices/cerca-go/internal/apijson"
+ "github.com/matrices/cerca-go/internal/apiquery"
+ "github.com/matrices/cerca-go/internal/param"
"github.com/matrices/cerca-go/internal/requestconfig"
"github.com/matrices/cerca-go/option"
- "github.com/matrices/cerca-go/shared"
+ "github.com/matrices/cerca-go/packages/pagination"
+ "github.com/tidwall/gjson"
)
// ToolService contains methods and other services that help with interacting with
@@ -34,160 +39,1715 @@ func NewToolService(opts ...option.RequestOption) (r *ToolService) {
return
}
-func (r *ToolService) ListForAgent(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ToolListForAgentResponse, err error) {
+// Tool Sources
+func (r *ToolService) New(ctx context.Context, fleetID string, body ToolNewParams, opts ...option.RequestOption) (res *ToolSource, err error) {
opts = slices.Concat(r.Options, opts)
- if agentID == "" {
- err = errors.New("missing required agentId parameter")
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
return nil, err
}
- path := fmt.Sprintf("agents/%s/tools", agentID)
+ path := fmt.Sprintf("fleets/%s/tool-sources", fleetID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// Tool Source
+func (r *ToolService) Get(ctx context.Context, fleetID string, sourceID string, opts ...option.RequestOption) (res *ToolSource, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ if sourceID == "" {
+ err = errors.New("missing required sourceId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
-type RuntimeDiscoveredTool struct {
- Approval RuntimeDiscoveredToolApproval `json:"approval" api:"required"`
- Description string `json:"description" api:"required"`
- // JSON Schema object describing tool input parameters.
- InputSchema map[string]interface{} `json:"inputSchema" api:"required"`
- Name string `json:"name" api:"required"`
- Origin RuntimeDiscoveredToolOrigin `json:"origin" api:"required"`
- Source string `json:"source" api:"required"`
- AccountLabel string `json:"accountLabel"`
- ConnectionID string `json:"connectionId"`
- ConnectionMetadata ToolConnectionMetadata `json:"connectionMetadata"`
- SourceID string `json:"sourceId"`
- SourceVersion float64 `json:"sourceVersion"`
- JSON runtimeDiscoveredToolJSON `json:"-"`
-}
-
-// runtimeDiscoveredToolJSON contains the JSON metadata for the struct
-// [RuntimeDiscoveredTool]
-type runtimeDiscoveredToolJSON struct {
- Approval apijson.Field
- Description apijson.Field
- InputSchema apijson.Field
- Name apijson.Field
- Origin apijson.Field
- Source apijson.Field
- AccountLabel apijson.Field
- ConnectionID apijson.Field
- ConnectionMetadata apijson.Field
- SourceID apijson.Field
- SourceVersion apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
+// Tool Source
+func (r *ToolService) Update(ctx context.Context, fleetID string, sourceID string, body ToolUpdateParams, opts ...option.RequestOption) (res *ToolSource, err error) {
+ opts = slices.Concat(r.Options, opts)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ if sourceID == "" {
+ err = errors.New("missing required sourceId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
+ return res, err
+}
+
+// Tool Sources
+func (r *ToolService) List(ctx context.Context, fleetID string, query ToolListParams, opts ...option.RequestOption) (res *pagination.SourcesCursorPage[ToolSource], err error) {
+ var raw *http.Response
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return nil, err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources", fleetID)
+ cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
+ if err != nil {
+ return nil, err
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+// Tool Sources
+func (r *ToolService) ListAutoPaging(ctx context.Context, fleetID string, query ToolListParams, opts ...option.RequestOption) *pagination.SourcesCursorPageAutoPager[ToolSource] {
+ return pagination.NewSourcesCursorPageAutoPager(r.List(ctx, fleetID, query, opts...))
+}
+
+// Tool Source
+func (r *ToolService) Delete(ctx context.Context, fleetID string, sourceID string, opts ...option.RequestOption) (err error) {
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
+ if fleetID == "" {
+ err = errors.New("missing required fleetId parameter")
+ return err
+ }
+ if sourceID == "" {
+ err = errors.New("missing required sourceId parameter")
+ return err
+ }
+ path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
+ return err
+}
+
+// Where an API key or OAuth access token should be injected into outgoing
+// tool-source requests.
+type AuthInjection struct {
+ Location AuthInjectionLocation `json:"location" api:"required"`
+ Name string `json:"name" api:"required"`
+ // Optional value template. For OAuth connection auth, use values such as
+ // `Bearer ${token}`.
+ Value string `json:"value"`
+ JSON authInjectionJSON `json:"-"`
+ union AuthInjectionUnion
+}
+
+// authInjectionJSON contains the JSON metadata for the struct [AuthInjection]
+type authInjectionJSON struct {
+ Location apijson.Field
+ Name apijson.Field
+ Value apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r authInjectionJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *AuthInjection) UnmarshalJSON(data []byte) (err error) {
+ *r = AuthInjection{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [AuthInjectionUnion] interface which you can cast to the
+// specific types for more type safety.
+//
+// Possible runtime types of the union are [AuthInjectionHeaderAuthInjection],
+// [AuthInjectionQueryAuthInjection].
+func (r AuthInjection) AsUnion() AuthInjectionUnion {
+ return r.union
+}
+
+// Where an API key or OAuth access token should be injected into outgoing
+// tool-source requests.
+//
+// Union satisfied by [AuthInjectionHeaderAuthInjection] or
+// [AuthInjectionQueryAuthInjection].
+type AuthInjectionUnion interface {
+ implementsAuthInjection()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*AuthInjectionUnion)(nil)).Elem(),
+ "location",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(AuthInjectionHeaderAuthInjection{}),
+ DiscriminatorValue: "header",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(AuthInjectionQueryAuthInjection{}),
+ DiscriminatorValue: "query",
+ },
+ )
+}
+
+type AuthInjectionHeaderAuthInjection struct {
+ Location AuthInjectionHeaderAuthInjectionLocation `json:"location" api:"required"`
+ Name string `json:"name" api:"required"`
+ // Optional value template. For OAuth connection auth, use values such as
+ // `Bearer ${token}`.
+ Value string `json:"value"`
+ JSON authInjectionHeaderAuthInjectionJSON `json:"-"`
+}
+
+// authInjectionHeaderAuthInjectionJSON contains the JSON metadata for the struct
+// [AuthInjectionHeaderAuthInjection]
+type authInjectionHeaderAuthInjectionJSON struct {
+ Location apijson.Field
+ Name apijson.Field
+ Value apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *AuthInjectionHeaderAuthInjection) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
}
-func (r *RuntimeDiscoveredTool) UnmarshalJSON(data []byte) (err error) {
+func (r authInjectionHeaderAuthInjectionJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r AuthInjectionHeaderAuthInjection) implementsAuthInjection() {}
+
+type AuthInjectionHeaderAuthInjectionLocation string
+
+const (
+ AuthInjectionHeaderAuthInjectionLocationHeader AuthInjectionHeaderAuthInjectionLocation = "header"
+)
+
+func (r AuthInjectionHeaderAuthInjectionLocation) IsKnown() bool {
+ switch r {
+ case AuthInjectionHeaderAuthInjectionLocationHeader:
+ return true
+ }
+ return false
+}
+
+type AuthInjectionQueryAuthInjection struct {
+ Location AuthInjectionQueryAuthInjectionLocation `json:"location" api:"required"`
+ Name string `json:"name" api:"required"`
+ JSON authInjectionQueryAuthInjectionJSON `json:"-"`
+}
+
+// authInjectionQueryAuthInjectionJSON contains the JSON metadata for the struct
+// [AuthInjectionQueryAuthInjection]
+type authInjectionQueryAuthInjectionJSON struct {
+ Location apijson.Field
+ Name apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *AuthInjectionQueryAuthInjection) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r runtimeDiscoveredToolJSON) RawJSON() string {
+func (r authInjectionQueryAuthInjectionJSON) RawJSON() string {
return r.raw
}
-type RuntimeDiscoveredToolApproval string
+func (r AuthInjectionQueryAuthInjection) implementsAuthInjection() {}
+
+type AuthInjectionQueryAuthInjectionLocation string
const (
- RuntimeDiscoveredToolApprovalAlways RuntimeDiscoveredToolApproval = "always"
- RuntimeDiscoveredToolApprovalNever RuntimeDiscoveredToolApproval = "never"
+ AuthInjectionQueryAuthInjectionLocationQuery AuthInjectionQueryAuthInjectionLocation = "query"
)
-func (r RuntimeDiscoveredToolApproval) IsKnown() bool {
+func (r AuthInjectionQueryAuthInjectionLocation) IsKnown() bool {
switch r {
- case RuntimeDiscoveredToolApprovalAlways, RuntimeDiscoveredToolApprovalNever:
+ case AuthInjectionQueryAuthInjectionLocationQuery:
return true
}
return false
}
-type RuntimeDiscoveredToolOrigin string
+type AuthInjectionLocation string
const (
- RuntimeDiscoveredToolOriginBuiltin RuntimeDiscoveredToolOrigin = "builtin"
- RuntimeDiscoveredToolOriginToolSource RuntimeDiscoveredToolOrigin = "tool_source"
+ AuthInjectionLocationHeader AuthInjectionLocation = "header"
+ AuthInjectionLocationQuery AuthInjectionLocation = "query"
)
-func (r RuntimeDiscoveredToolOrigin) IsKnown() bool {
+func (r AuthInjectionLocation) IsKnown() bool {
switch r {
- case RuntimeDiscoveredToolOriginBuiltin, RuntimeDiscoveredToolOriginToolSource:
+ case AuthInjectionLocationHeader, AuthInjectionLocationQuery:
return true
}
return false
}
-type RuntimeSourceWarning struct {
- Message string `json:"message" api:"required"`
- Source string `json:"source" api:"required"`
- SourceID string `json:"sourceId"`
- JSON runtimeSourceWarningJSON `json:"-"`
+// Where an API key or OAuth access token should be injected into outgoing
+// tool-source requests.
+type AuthInjectionParam struct {
+ Location param.Field[AuthInjectionLocation] `json:"location" api:"required"`
+ Name param.Field[string] `json:"name" api:"required"`
+ // Optional value template. For OAuth connection auth, use values such as
+ // `Bearer ${token}`.
+ Value param.Field[string] `json:"value"`
+}
+
+func (r AuthInjectionParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r AuthInjectionParam) implementsAuthInjectionUnionParam() {}
+
+// Where an API key or OAuth access token should be injected into outgoing
+// tool-source requests.
+//
+// Satisfied by [AuthInjectionHeaderAuthInjectionParam],
+// [AuthInjectionQueryAuthInjectionParam], [AuthInjectionParam].
+type AuthInjectionUnionParam interface {
+ implementsAuthInjectionUnionParam()
+}
+
+type AuthInjectionHeaderAuthInjectionParam struct {
+ Location param.Field[AuthInjectionHeaderAuthInjectionLocation] `json:"location" api:"required"`
+ Name param.Field[string] `json:"name" api:"required"`
+ // Optional value template. For OAuth connection auth, use values such as
+ // `Bearer ${token}`.
+ Value param.Field[string] `json:"value"`
+}
+
+func (r AuthInjectionHeaderAuthInjectionParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
}
-// runtimeSourceWarningJSON contains the JSON metadata for the struct
-// [RuntimeSourceWarning]
-type runtimeSourceWarningJSON struct {
- Message apijson.Field
- Source apijson.Field
- SourceID apijson.Field
+func (r AuthInjectionHeaderAuthInjectionParam) implementsAuthInjectionUnionParam() {}
+
+type AuthInjectionQueryAuthInjectionParam struct {
+ Location param.Field[AuthInjectionQueryAuthInjectionLocation] `json:"location" api:"required"`
+ Name param.Field[string] `json:"name" api:"required"`
+}
+
+func (r AuthInjectionQueryAuthInjectionParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r AuthInjectionQueryAuthInjectionParam) implementsAuthInjectionUnionParam() {}
+
+// HTTP endpoint invoked when the tool is called.
+type HTTPEndpoint struct {
+ Method HTTPEndpointMethod `json:"method" api:"required"`
+ URL string `json:"url" api:"required"`
+ Body HTTPEndpointBody `json:"body"`
+ Headers map[string]string `json:"headers"`
+ Path map[string]string `json:"path"`
+ Query map[string]string `json:"query"`
+ JSON httpEndpointJSON `json:"-"`
+}
+
+// httpEndpointJSON contains the JSON metadata for the struct [HTTPEndpoint]
+type httpEndpointJSON struct {
+ Method apijson.Field
+ URL apijson.Field
+ Body apijson.Field
+ Headers apijson.Field
+ Path apijson.Field
+ Query apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *RuntimeSourceWarning) UnmarshalJSON(data []byte) (err error) {
+func (r *HTTPEndpoint) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r runtimeSourceWarningJSON) RawJSON() string {
+func (r httpEndpointJSON) RawJSON() string {
return r.raw
}
-type RuntimeToolDescriptor struct {
- Description string `json:"description" api:"required"`
- InputSchema shared.JsonObject `json:"inputSchema" api:"required"`
- Name shared.ToolName `json:"name" api:"required"`
- JSON runtimeToolDescriptorJSON `json:"-"`
+type HTTPEndpointMethod string
+
+const (
+ HTTPEndpointMethodGet HTTPEndpointMethod = "GET"
+ HTTPEndpointMethodPost HTTPEndpointMethod = "POST"
+ HTTPEndpointMethodPut HTTPEndpointMethod = "PUT"
+ HTTPEndpointMethodPatch HTTPEndpointMethod = "PATCH"
+ HTTPEndpointMethodDelete HTTPEndpointMethod = "DELETE"
+)
+
+func (r HTTPEndpointMethod) IsKnown() bool {
+ switch r {
+ case HTTPEndpointMethodGet, HTTPEndpointMethodPost, HTTPEndpointMethodPut, HTTPEndpointMethodPatch, HTTPEndpointMethodDelete:
+ return true
+ }
+ return false
+}
+
+type HTTPEndpointBody string
+
+const (
+ HTTPEndpointBodyJsonParams HTTPEndpointBody = "json_params"
+)
+
+func (r HTTPEndpointBody) IsKnown() bool {
+ switch r {
+ case HTTPEndpointBodyJsonParams:
+ return true
+ }
+ return false
+}
+
+// HTTP endpoint invoked when the tool is called.
+type HTTPEndpointParam struct {
+ Method param.Field[HTTPEndpointMethod] `json:"method" api:"required"`
+ URL param.Field[string] `json:"url" api:"required"`
+ Body param.Field[HTTPEndpointBody] `json:"body"`
+ Headers param.Field[map[string]string] `json:"headers"`
+ Path param.Field[map[string]string] `json:"path"`
+ Query param.Field[map[string]string] `json:"query"`
+}
+
+func (r HTTPEndpointParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+// Definition for a single HTTP tool exposed by a tool source.
+type HTTPToolDefinition struct {
+ Description string `json:"description" api:"required"`
+ // HTTP endpoint invoked when the tool is called.
+ Endpoint HTTPEndpoint `json:"endpoint" api:"required"`
+ // JSON Schema object describing tool input parameters.
+ InputSchema map[string]interface{} `json:"inputSchema" api:"required"`
+ Name string `json:"name" api:"required"`
+ Approval ToolApprovalMode `json:"approval"`
+ // HTTP tool execution retry and timeout policy.
+ Execution HTTPToolExecutionPolicy `json:"execution"`
+ // How the HTTP response should be normalized for the agent.
+ Response ResponseNormalizationHint `json:"response"`
+ JSON httpToolDefinitionJSON `json:"-"`
}
-// runtimeToolDescriptorJSON contains the JSON metadata for the struct
-// [RuntimeToolDescriptor]
-type runtimeToolDescriptorJSON struct {
+// httpToolDefinitionJSON contains the JSON metadata for the struct
+// [HTTPToolDefinition]
+type httpToolDefinitionJSON struct {
Description apijson.Field
+ Endpoint apijson.Field
InputSchema apijson.Field
Name apijson.Field
+ Approval apijson.Field
+ Execution apijson.Field
+ Response apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *HTTPToolDefinition) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r httpToolDefinitionJSON) RawJSON() string {
+ return r.raw
+}
+
+// Definition for a single HTTP tool exposed by a tool source.
+type HTTPToolDefinitionParam struct {
+ Description param.Field[string] `json:"description" api:"required"`
+ // HTTP endpoint invoked when the tool is called.
+ Endpoint param.Field[HTTPEndpointParam] `json:"endpoint" api:"required"`
+ // JSON Schema object describing tool input parameters.
+ InputSchema param.Field[map[string]interface{}] `json:"inputSchema" api:"required"`
+ Name param.Field[string] `json:"name" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ // HTTP tool execution retry and timeout policy.
+ Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
+ // How the HTTP response should be normalized for the agent.
+ Response param.Field[ResponseNormalizationHintParam] `json:"response"`
+}
+
+func (r HTTPToolDefinitionParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+// HTTP tool execution retry and timeout policy.
+type HTTPToolExecutionPolicy struct {
+ IdempotencyKeyHeader string `json:"idempotencyKeyHeader"`
+ MaxAttempts float64 `json:"maxAttempts"`
+ RetryMode HTTPToolExecutionPolicyRetryMode `json:"retryMode"`
+ TimeoutMs float64 `json:"timeoutMs"`
+ JSON httpToolExecutionPolicyJSON `json:"-"`
+}
+
+// httpToolExecutionPolicyJSON contains the JSON metadata for the struct
+// [HTTPToolExecutionPolicy]
+type httpToolExecutionPolicyJSON struct {
+ IdempotencyKeyHeader apijson.Field
+ MaxAttempts apijson.Field
+ RetryMode apijson.Field
+ TimeoutMs apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *HTTPToolExecutionPolicy) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r httpToolExecutionPolicyJSON) RawJSON() string {
+ return r.raw
+}
+
+type HTTPToolExecutionPolicyRetryMode string
+
+const (
+ HTTPToolExecutionPolicyRetryModeDisabled HTTPToolExecutionPolicyRetryMode = "disabled"
+ HTTPToolExecutionPolicyRetryModeSafeOnly HTTPToolExecutionPolicyRetryMode = "safe_only"
+ HTTPToolExecutionPolicyRetryModeEnabled HTTPToolExecutionPolicyRetryMode = "enabled"
+)
+
+func (r HTTPToolExecutionPolicyRetryMode) IsKnown() bool {
+ switch r {
+ case HTTPToolExecutionPolicyRetryModeDisabled, HTTPToolExecutionPolicyRetryModeSafeOnly, HTTPToolExecutionPolicyRetryModeEnabled:
+ return true
+ }
+ return false
+}
+
+// HTTP tool execution retry and timeout policy.
+type HTTPToolExecutionPolicyParam struct {
+ IdempotencyKeyHeader param.Field[string] `json:"idempotencyKeyHeader"`
+ MaxAttempts param.Field[float64] `json:"maxAttempts"`
+ RetryMode param.Field[HTTPToolExecutionPolicyRetryMode] `json:"retryMode"`
+ TimeoutMs param.Field[float64] `json:"timeoutMs"`
+}
+
+func (r HTTPToolExecutionPolicyParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type HTTPToolSource struct {
+ ID string `json:"id" api:"required"`
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth ToolSourceAuth `json:"auth" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ Namespace string `json:"namespace" api:"required"`
+ Tools []HTTPToolDefinition `json:"tools" api:"required"`
+ Type HTTPToolSourceType `json:"type" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ Approval ToolApprovalMode `json:"approval"`
+ // HTTP tool execution retry and timeout policy.
+ Execution HTTPToolExecutionPolicy `json:"execution"`
+ JSON httpToolSourceJSON `json:"-"`
+}
+
+// httpToolSourceJSON contains the JSON metadata for the struct [HTTPToolSource]
+type httpToolSourceJSON struct {
+ ID apijson.Field
+ Auth apijson.Field
+ CreatedAt apijson.Field
+ Enabled apijson.Field
+ FleetID apijson.Field
+ Namespace apijson.Field
+ Tools apijson.Field
+ Type apijson.Field
+ UpdatedAt apijson.Field
+ Version apijson.Field
+ Approval apijson.Field
+ Execution apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *HTTPToolSource) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r httpToolSourceJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r HTTPToolSource) implementsToolSource() {}
+
+type HTTPToolSourceType string
+
+const (
+ HTTPToolSourceTypeHTTP HTTPToolSourceType = "http"
+)
+
+func (r HTTPToolSourceType) IsKnown() bool {
+ switch r {
+ case HTTPToolSourceTypeHTTP:
+ return true
+ }
+ return false
+}
+
+// MCP discovery and execution retry/timeout policy.
+type McpToolExecutionPolicy struct {
+ DiscoveryTimeoutMs float64 `json:"discoveryTimeoutMs"`
+ ExecutionTimeoutMs float64 `json:"executionTimeoutMs"`
+ MaxAttempts float64 `json:"maxAttempts"`
+ RetryMode McpToolExecutionPolicyRetryMode `json:"retryMode"`
+ JSON mcpToolExecutionPolicyJSON `json:"-"`
+}
+
+// mcpToolExecutionPolicyJSON contains the JSON metadata for the struct
+// [McpToolExecutionPolicy]
+type mcpToolExecutionPolicyJSON struct {
+ DiscoveryTimeoutMs apijson.Field
+ ExecutionTimeoutMs apijson.Field
+ MaxAttempts apijson.Field
+ RetryMode apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *McpToolExecutionPolicy) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r mcpToolExecutionPolicyJSON) RawJSON() string {
+ return r.raw
+}
+
+type McpToolExecutionPolicyRetryMode string
+
+const (
+ McpToolExecutionPolicyRetryModeDisabled McpToolExecutionPolicyRetryMode = "disabled"
+ McpToolExecutionPolicyRetryModeConnectOnly McpToolExecutionPolicyRetryMode = "connect_only"
+ McpToolExecutionPolicyRetryModeEnabled McpToolExecutionPolicyRetryMode = "enabled"
+)
+
+func (r McpToolExecutionPolicyRetryMode) IsKnown() bool {
+ switch r {
+ case McpToolExecutionPolicyRetryModeDisabled, McpToolExecutionPolicyRetryModeConnectOnly, McpToolExecutionPolicyRetryModeEnabled:
+ return true
+ }
+ return false
+}
+
+// MCP discovery and execution retry/timeout policy.
+type McpToolExecutionPolicyParam struct {
+ DiscoveryTimeoutMs param.Field[float64] `json:"discoveryTimeoutMs"`
+ ExecutionTimeoutMs param.Field[float64] `json:"executionTimeoutMs"`
+ MaxAttempts param.Field[float64] `json:"maxAttempts"`
+ RetryMode param.Field[McpToolExecutionPolicyRetryMode] `json:"retryMode"`
+}
+
+func (r McpToolExecutionPolicyParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type McpToolSource struct {
+ ID string `json:"id" api:"required"`
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth ToolSourceAuth `json:"auth" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ Namespace string `json:"namespace" api:"required"`
+ Type McpToolSourceType `json:"type" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ URL string `json:"url" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ Approval ToolApprovalMode `json:"approval"`
+ // MCP discovery and execution retry/timeout policy.
+ Execution McpToolExecutionPolicy `json:"execution"`
+ JSON mcpToolSourceJSON `json:"-"`
+}
+
+// mcpToolSourceJSON contains the JSON metadata for the struct [McpToolSource]
+type mcpToolSourceJSON struct {
+ ID apijson.Field
+ Auth apijson.Field
+ CreatedAt apijson.Field
+ Enabled apijson.Field
+ FleetID apijson.Field
+ Namespace apijson.Field
+ Type apijson.Field
+ UpdatedAt apijson.Field
+ URL apijson.Field
+ Version apijson.Field
+ Approval apijson.Field
+ Execution apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *RuntimeToolDescriptor) UnmarshalJSON(data []byte) (err error) {
+func (r *McpToolSource) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r runtimeToolDescriptorJSON) RawJSON() string {
+func (r mcpToolSourceJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r McpToolSource) implementsToolSource() {}
+
+type McpToolSourceType string
+
+const (
+ McpToolSourceTypeMcp McpToolSourceType = "mcp"
+)
+
+func (r McpToolSourceType) IsKnown() bool {
+ switch r {
+ case McpToolSourceTypeMcp:
+ return true
+ }
+ return false
+}
+
+// Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+// stored client secrets and assertions.
+type OAuthExchangeConfig struct {
+ GrantType OAuthExchangeConfigGrantType `json:"grantType" api:"required"`
+ TokenURL string `json:"tokenUrl" api:"required"`
+ AssertionConnectionID string `json:"assertionConnectionId"`
+ Audience string `json:"audience"`
+ ClientID string `json:"clientId"`
+ ClientSecretConnectionID string `json:"clientSecretConnectionId"`
+ // This field can have the runtime type of [map[string]string].
+ ExtraParams interface{} `json:"extraParams"`
+ Issuer string `json:"issuer"`
+ // This field can have the runtime type of [[]string].
+ Scopes interface{} `json:"scopes"`
+ Subject string `json:"subject"`
+ JSON oauthExchangeConfigJSON `json:"-"`
+ union OAuthExchangeConfigUnion
+}
+
+// oauthExchangeConfigJSON contains the JSON metadata for the struct
+// [OAuthExchangeConfig]
+type oauthExchangeConfigJSON struct {
+ GrantType apijson.Field
+ TokenURL apijson.Field
+ AssertionConnectionID apijson.Field
+ Audience apijson.Field
+ ClientID apijson.Field
+ ClientSecretConnectionID apijson.Field
+ ExtraParams apijson.Field
+ Issuer apijson.Field
+ Scopes apijson.Field
+ Subject apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r oauthExchangeConfigJSON) RawJSON() string {
return r.raw
}
-type ToolListForAgentResponse struct {
- DiscoveredTools []RuntimeDiscoveredTool `json:"discoveredTools" api:"required"`
- Tools []RuntimeToolDescriptor `json:"tools" api:"required"`
- SourceWarnings []RuntimeSourceWarning `json:"sourceWarnings"`
- JSON toolListForAgentResponseJSON `json:"-"`
+func (r *OAuthExchangeConfig) UnmarshalJSON(data []byte) (err error) {
+ *r = OAuthExchangeConfig{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [OAuthExchangeConfigUnion] interface which you can cast to the
+// specific types for more type safety.
+//
+// Possible runtime types of the union are
+// [OAuthExchangeConfigClientCredentialsOAuthExchange],
+// [OAuthExchangeConfigJwtBearerOAuthExchange].
+func (r OAuthExchangeConfig) AsUnion() OAuthExchangeConfigUnion {
+ return r.union
+}
+
+// Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+// stored client secrets and assertions.
+//
+// Union satisfied by [OAuthExchangeConfigClientCredentialsOAuthExchange] or
+// [OAuthExchangeConfigJwtBearerOAuthExchange].
+type OAuthExchangeConfigUnion interface {
+ implementsOAuthExchangeConfig()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*OAuthExchangeConfigUnion)(nil)).Elem(),
+ "grantType",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(OAuthExchangeConfigClientCredentialsOAuthExchange{}),
+ DiscriminatorValue: "client_credentials",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(OAuthExchangeConfigJwtBearerOAuthExchange{}),
+ DiscriminatorValue: "jwt_bearer",
+ },
+ )
+}
+
+type OAuthExchangeConfigClientCredentialsOAuthExchange struct {
+ ClientID string `json:"clientId" api:"required"`
+ ClientSecretConnectionID string `json:"clientSecretConnectionId" api:"required"`
+ GrantType OAuthExchangeConfigClientCredentialsOAuthExchangeGrantType `json:"grantType" api:"required"`
+ TokenURL string `json:"tokenUrl" api:"required"`
+ Audience string `json:"audience"`
+ ExtraParams map[string]string `json:"extraParams"`
+ Scopes []string `json:"scopes"`
+ JSON oauthExchangeConfigClientCredentialsOAuthExchangeJSON `json:"-"`
}
-// toolListForAgentResponseJSON contains the JSON metadata for the struct
-// [ToolListForAgentResponse]
-type toolListForAgentResponseJSON struct {
- DiscoveredTools apijson.Field
- Tools apijson.Field
- SourceWarnings apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
+// oauthExchangeConfigClientCredentialsOAuthExchangeJSON contains the JSON metadata
+// for the struct [OAuthExchangeConfigClientCredentialsOAuthExchange]
+type oauthExchangeConfigClientCredentialsOAuthExchangeJSON struct {
+ ClientID apijson.Field
+ ClientSecretConnectionID apijson.Field
+ GrantType apijson.Field
+ TokenURL apijson.Field
+ Audience apijson.Field
+ ExtraParams apijson.Field
+ Scopes apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
}
-func (r *ToolListForAgentResponse) UnmarshalJSON(data []byte) (err error) {
+func (r *OAuthExchangeConfigClientCredentialsOAuthExchange) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r toolListForAgentResponseJSON) RawJSON() string {
+func (r oauthExchangeConfigClientCredentialsOAuthExchangeJSON) RawJSON() string {
return r.raw
}
+
+func (r OAuthExchangeConfigClientCredentialsOAuthExchange) implementsOAuthExchangeConfig() {}
+
+type OAuthExchangeConfigClientCredentialsOAuthExchangeGrantType string
+
+const (
+ OAuthExchangeConfigClientCredentialsOAuthExchangeGrantTypeClientCredentials OAuthExchangeConfigClientCredentialsOAuthExchangeGrantType = "client_credentials"
+)
+
+func (r OAuthExchangeConfigClientCredentialsOAuthExchangeGrantType) IsKnown() bool {
+ switch r {
+ case OAuthExchangeConfigClientCredentialsOAuthExchangeGrantTypeClientCredentials:
+ return true
+ }
+ return false
+}
+
+type OAuthExchangeConfigJwtBearerOAuthExchange struct {
+ AssertionConnectionID string `json:"assertionConnectionId" api:"required"`
+ Audience string `json:"audience" api:"required"`
+ GrantType OAuthExchangeConfigJwtBearerOAuthExchangeGrantType `json:"grantType" api:"required"`
+ Issuer string `json:"issuer" api:"required"`
+ TokenURL string `json:"tokenUrl" api:"required"`
+ ExtraParams map[string]string `json:"extraParams"`
+ Scopes []string `json:"scopes"`
+ Subject string `json:"subject"`
+ JSON oauthExchangeConfigJwtBearerOAuthExchangeJSON `json:"-"`
+}
+
+// oauthExchangeConfigJwtBearerOAuthExchangeJSON contains the JSON metadata for the
+// struct [OAuthExchangeConfigJwtBearerOAuthExchange]
+type oauthExchangeConfigJwtBearerOAuthExchangeJSON struct {
+ AssertionConnectionID apijson.Field
+ Audience apijson.Field
+ GrantType apijson.Field
+ Issuer apijson.Field
+ TokenURL apijson.Field
+ ExtraParams apijson.Field
+ Scopes apijson.Field
+ Subject apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *OAuthExchangeConfigJwtBearerOAuthExchange) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r oauthExchangeConfigJwtBearerOAuthExchangeJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r OAuthExchangeConfigJwtBearerOAuthExchange) implementsOAuthExchangeConfig() {}
+
+type OAuthExchangeConfigJwtBearerOAuthExchangeGrantType string
+
+const (
+ OAuthExchangeConfigJwtBearerOAuthExchangeGrantTypeJwtBearer OAuthExchangeConfigJwtBearerOAuthExchangeGrantType = "jwt_bearer"
+)
+
+func (r OAuthExchangeConfigJwtBearerOAuthExchangeGrantType) IsKnown() bool {
+ switch r {
+ case OAuthExchangeConfigJwtBearerOAuthExchangeGrantTypeJwtBearer:
+ return true
+ }
+ return false
+}
+
+type OAuthExchangeConfigGrantType string
+
+const (
+ OAuthExchangeConfigGrantTypeClientCredentials OAuthExchangeConfigGrantType = "client_credentials"
+ OAuthExchangeConfigGrantTypeJwtBearer OAuthExchangeConfigGrantType = "jwt_bearer"
+)
+
+func (r OAuthExchangeConfigGrantType) IsKnown() bool {
+ switch r {
+ case OAuthExchangeConfigGrantTypeClientCredentials, OAuthExchangeConfigGrantTypeJwtBearer:
+ return true
+ }
+ return false
+}
+
+// Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+// stored client secrets and assertions.
+type OAuthExchangeConfigParam struct {
+ GrantType param.Field[OAuthExchangeConfigGrantType] `json:"grantType" api:"required"`
+ TokenURL param.Field[string] `json:"tokenUrl" api:"required"`
+ AssertionConnectionID param.Field[string] `json:"assertionConnectionId"`
+ Audience param.Field[string] `json:"audience"`
+ ClientID param.Field[string] `json:"clientId"`
+ ClientSecretConnectionID param.Field[string] `json:"clientSecretConnectionId"`
+ ExtraParams param.Field[interface{}] `json:"extraParams"`
+ Issuer param.Field[string] `json:"issuer"`
+ Scopes param.Field[interface{}] `json:"scopes"`
+ Subject param.Field[string] `json:"subject"`
+}
+
+func (r OAuthExchangeConfigParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r OAuthExchangeConfigParam) implementsOAuthExchangeConfigUnionParam() {}
+
+// Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+// stored client secrets and assertions.
+//
+// Satisfied by [OAuthExchangeConfigClientCredentialsOAuthExchangeParam],
+// [OAuthExchangeConfigJwtBearerOAuthExchangeParam], [OAuthExchangeConfigParam].
+type OAuthExchangeConfigUnionParam interface {
+ implementsOAuthExchangeConfigUnionParam()
+}
+
+type OAuthExchangeConfigClientCredentialsOAuthExchangeParam struct {
+ ClientID param.Field[string] `json:"clientId" api:"required"`
+ ClientSecretConnectionID param.Field[string] `json:"clientSecretConnectionId" api:"required"`
+ GrantType param.Field[OAuthExchangeConfigClientCredentialsOAuthExchangeGrantType] `json:"grantType" api:"required"`
+ TokenURL param.Field[string] `json:"tokenUrl" api:"required"`
+ Audience param.Field[string] `json:"audience"`
+ ExtraParams param.Field[map[string]string] `json:"extraParams"`
+ Scopes param.Field[[]string] `json:"scopes"`
+}
+
+func (r OAuthExchangeConfigClientCredentialsOAuthExchangeParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r OAuthExchangeConfigClientCredentialsOAuthExchangeParam) implementsOAuthExchangeConfigUnionParam() {
+}
+
+type OAuthExchangeConfigJwtBearerOAuthExchangeParam struct {
+ AssertionConnectionID param.Field[string] `json:"assertionConnectionId" api:"required"`
+ Audience param.Field[string] `json:"audience" api:"required"`
+ GrantType param.Field[OAuthExchangeConfigJwtBearerOAuthExchangeGrantType] `json:"grantType" api:"required"`
+ Issuer param.Field[string] `json:"issuer" api:"required"`
+ TokenURL param.Field[string] `json:"tokenUrl" api:"required"`
+ ExtraParams param.Field[map[string]string] `json:"extraParams"`
+ Scopes param.Field[[]string] `json:"scopes"`
+ Subject param.Field[string] `json:"subject"`
+}
+
+func (r OAuthExchangeConfigJwtBearerOAuthExchangeParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r OAuthExchangeConfigJwtBearerOAuthExchangeParam) implementsOAuthExchangeConfigUnionParam() {}
+
+// How the HTTP response should be normalized for the agent.
+type ResponseNormalizationHint struct {
+ Mode ResponseNormalizationHintMode `json:"mode" api:"required"`
+ JSON responseNormalizationHintJSON `json:"-"`
+}
+
+// responseNormalizationHintJSON contains the JSON metadata for the struct
+// [ResponseNormalizationHint]
+type responseNormalizationHintJSON struct {
+ Mode apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ResponseNormalizationHint) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r responseNormalizationHintJSON) RawJSON() string {
+ return r.raw
+}
+
+type ResponseNormalizationHintMode string
+
+const (
+ ResponseNormalizationHintModeAuto ResponseNormalizationHintMode = "auto"
+ ResponseNormalizationHintModeJson ResponseNormalizationHintMode = "json"
+ ResponseNormalizationHintModeMarkdown ResponseNormalizationHintMode = "markdown"
+ ResponseNormalizationHintModeBlob ResponseNormalizationHintMode = "blob"
+)
+
+func (r ResponseNormalizationHintMode) IsKnown() bool {
+ switch r {
+ case ResponseNormalizationHintModeAuto, ResponseNormalizationHintModeJson, ResponseNormalizationHintModeMarkdown, ResponseNormalizationHintModeBlob:
+ return true
+ }
+ return false
+}
+
+// How the HTTP response should be normalized for the agent.
+type ResponseNormalizationHintParam struct {
+ Mode param.Field[ResponseNormalizationHintMode] `json:"mode" api:"required"`
+}
+
+func (r ResponseNormalizationHintParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type ToolApprovalMode string
+
+const (
+ ToolApprovalModeAlways ToolApprovalMode = "always"
+ ToolApprovalModeNever ToolApprovalMode = "never"
+)
+
+func (r ToolApprovalMode) IsKnown() bool {
+ switch r {
+ case ToolApprovalModeAlways, ToolApprovalModeNever:
+ return true
+ }
+ return false
+}
+
+type ToolSource struct {
+ ID string `json:"id" api:"required"`
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth ToolSourceAuth `json:"auth" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Enabled bool `json:"enabled" api:"required"`
+ FleetID string `json:"fleetId" api:"required"`
+ Namespace string `json:"namespace" api:"required"`
+ Type ToolSourceType `json:"type" api:"required"`
+ UpdatedAt string `json:"updatedAt" api:"required"`
+ Version float64 `json:"version" api:"required"`
+ Approval ToolApprovalMode `json:"approval"`
+ // This field can have the runtime type of [HTTPToolExecutionPolicy],
+ // [McpToolExecutionPolicy].
+ Execution interface{} `json:"execution"`
+ // This field can have the runtime type of [[]HTTPToolDefinition].
+ Tools interface{} `json:"tools"`
+ URL string `json:"url"`
+ JSON toolSourceJSON `json:"-"`
+ union ToolSourceUnion
+}
+
+// toolSourceJSON contains the JSON metadata for the struct [ToolSource]
+type toolSourceJSON struct {
+ ID apijson.Field
+ Auth apijson.Field
+ CreatedAt apijson.Field
+ Enabled apijson.Field
+ FleetID apijson.Field
+ Namespace apijson.Field
+ Type apijson.Field
+ UpdatedAt apijson.Field
+ Version apijson.Field
+ Approval apijson.Field
+ Execution apijson.Field
+ Tools apijson.Field
+ URL apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r toolSourceJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *ToolSource) UnmarshalJSON(data []byte) (err error) {
+ *r = ToolSource{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [ToolSourceUnion] interface which you can cast to the specific
+// types for more type safety.
+//
+// Possible runtime types of the union are [HTTPToolSource], [McpToolSource].
+func (r ToolSource) AsUnion() ToolSourceUnion {
+ return r.union
+}
+
+// Union satisfied by [HTTPToolSource] or [McpToolSource].
+type ToolSourceUnion interface {
+ implementsToolSource()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ToolSourceUnion)(nil)).Elem(),
+ "type",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(HTTPToolSource{}),
+ DiscriminatorValue: "http",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(McpToolSource{}),
+ DiscriminatorValue: "mcp",
+ },
+ )
+}
+
+type ToolSourceType string
+
+const (
+ ToolSourceTypeHTTP ToolSourceType = "http"
+ ToolSourceTypeMcp ToolSourceType = "mcp"
+)
+
+func (r ToolSourceType) IsKnown() bool {
+ switch r {
+ case ToolSourceTypeHTTP, ToolSourceTypeMcp:
+ return true
+ }
+ return false
+}
+
+// Tool source authentication configuration. The `kind` field selects one of
+// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+type ToolSourceAuth struct {
+ Kind ToolSourceAuthKind `json:"kind" api:"required"`
+ ConnectionID string `json:"connectionId"`
+ // Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+ // stored client secrets and assertions.
+ Exchange OAuthExchangeConfig `json:"exchange"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject AuthInjection `json:"inject"`
+ Provider string `json:"provider"`
+ // This field can have the runtime type of [[]string].
+ RequiredScopes interface{} `json:"requiredScopes"`
+ JSON toolSourceAuthJSON `json:"-"`
+ union ToolSourceAuthUnion
+}
+
+// toolSourceAuthJSON contains the JSON metadata for the struct [ToolSourceAuth]
+type toolSourceAuthJSON struct {
+ Kind apijson.Field
+ ConnectionID apijson.Field
+ Exchange apijson.Field
+ Inject apijson.Field
+ Provider apijson.Field
+ RequiredScopes apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r toolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *ToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ *r = ToolSourceAuth{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [ToolSourceAuthUnion] interface which you can cast to the
+// specific types for more type safety.
+//
+// Possible runtime types of the union are [ToolSourceAuthNoToolSourceAuth],
+// [ToolSourceAuthAPIKeyToolSourceAuth],
+// [ToolSourceAuthOAuthExchangeToolSourceAuth],
+// [ToolSourceAuthOAuthConnectionToolSourceAuth].
+func (r ToolSourceAuth) AsUnion() ToolSourceAuthUnion {
+ return r.union
+}
+
+// Tool source authentication configuration. The `kind` field selects one of
+// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+//
+// Union satisfied by [ToolSourceAuthNoToolSourceAuth],
+// [ToolSourceAuthAPIKeyToolSourceAuth],
+// [ToolSourceAuthOAuthExchangeToolSourceAuth] or
+// [ToolSourceAuthOAuthConnectionToolSourceAuth].
+type ToolSourceAuthUnion interface {
+ implementsToolSourceAuth()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ToolSourceAuthUnion)(nil)).Elem(),
+ "kind",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolSourceAuthNoToolSourceAuth{}),
+ DiscriminatorValue: "none",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolSourceAuthAPIKeyToolSourceAuth{}),
+ DiscriminatorValue: "api_key",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolSourceAuthOAuthExchangeToolSourceAuth{}),
+ DiscriminatorValue: "oauth_exchange",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolSourceAuthOAuthConnectionToolSourceAuth{}),
+ DiscriminatorValue: "oauth_connection",
+ },
+ )
+}
+
+type ToolSourceAuthNoToolSourceAuth struct {
+ Kind ToolSourceAuthNoToolSourceAuthKind `json:"kind" api:"required"`
+ JSON toolSourceAuthNoToolSourceAuthJSON `json:"-"`
+}
+
+// toolSourceAuthNoToolSourceAuthJSON contains the JSON metadata for the struct
+// [ToolSourceAuthNoToolSourceAuth]
+type toolSourceAuthNoToolSourceAuthJSON struct {
+ Kind apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ToolSourceAuthNoToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r toolSourceAuthNoToolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ToolSourceAuthNoToolSourceAuth) implementsToolSourceAuth() {}
+
+type ToolSourceAuthNoToolSourceAuthKind string
+
+const (
+ ToolSourceAuthNoToolSourceAuthKindNone ToolSourceAuthNoToolSourceAuthKind = "none"
+)
+
+func (r ToolSourceAuthNoToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case ToolSourceAuthNoToolSourceAuthKindNone:
+ return true
+ }
+ return false
+}
+
+type ToolSourceAuthAPIKeyToolSourceAuth struct {
+ ConnectionID string `json:"connectionId" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject AuthInjection `json:"inject" api:"required"`
+ Kind ToolSourceAuthAPIKeyToolSourceAuthKind `json:"kind" api:"required"`
+ JSON toolSourceAuthAPIKeyToolSourceAuthJSON `json:"-"`
+}
+
+// toolSourceAuthAPIKeyToolSourceAuthJSON contains the JSON metadata for the struct
+// [ToolSourceAuthAPIKeyToolSourceAuth]
+type toolSourceAuthAPIKeyToolSourceAuthJSON struct {
+ ConnectionID apijson.Field
+ Inject apijson.Field
+ Kind apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ToolSourceAuthAPIKeyToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r toolSourceAuthAPIKeyToolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ToolSourceAuthAPIKeyToolSourceAuth) implementsToolSourceAuth() {}
+
+type ToolSourceAuthAPIKeyToolSourceAuthKind string
+
+const (
+ ToolSourceAuthAPIKeyToolSourceAuthKindAPIKey ToolSourceAuthAPIKeyToolSourceAuthKind = "api_key"
+)
+
+func (r ToolSourceAuthAPIKeyToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case ToolSourceAuthAPIKeyToolSourceAuthKindAPIKey:
+ return true
+ }
+ return false
+}
+
+type ToolSourceAuthOAuthExchangeToolSourceAuth struct {
+ // Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+ // stored client secrets and assertions.
+ Exchange OAuthExchangeConfig `json:"exchange" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject AuthInjection `json:"inject" api:"required"`
+ Kind ToolSourceAuthOAuthExchangeToolSourceAuthKind `json:"kind" api:"required"`
+ JSON toolSourceAuthOAuthExchangeToolSourceAuthJSON `json:"-"`
+}
+
+// toolSourceAuthOAuthExchangeToolSourceAuthJSON contains the JSON metadata for the
+// struct [ToolSourceAuthOAuthExchangeToolSourceAuth]
+type toolSourceAuthOAuthExchangeToolSourceAuthJSON struct {
+ Exchange apijson.Field
+ Inject apijson.Field
+ Kind apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ToolSourceAuthOAuthExchangeToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r toolSourceAuthOAuthExchangeToolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ToolSourceAuthOAuthExchangeToolSourceAuth) implementsToolSourceAuth() {}
+
+type ToolSourceAuthOAuthExchangeToolSourceAuthKind string
+
+const (
+ ToolSourceAuthOAuthExchangeToolSourceAuthKindOAuthExchange ToolSourceAuthOAuthExchangeToolSourceAuthKind = "oauth_exchange"
+)
+
+func (r ToolSourceAuthOAuthExchangeToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case ToolSourceAuthOAuthExchangeToolSourceAuthKindOAuthExchange:
+ return true
+ }
+ return false
+}
+
+type ToolSourceAuthOAuthConnectionToolSourceAuth struct {
+ Kind ToolSourceAuthOAuthConnectionToolSourceAuthKind `json:"kind" api:"required"`
+ Provider string `json:"provider" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject AuthInjection `json:"inject"`
+ RequiredScopes []string `json:"requiredScopes"`
+ JSON toolSourceAuthOAuthConnectionToolSourceAuthJSON `json:"-"`
+}
+
+// toolSourceAuthOAuthConnectionToolSourceAuthJSON contains the JSON metadata for
+// the struct [ToolSourceAuthOAuthConnectionToolSourceAuth]
+type toolSourceAuthOAuthConnectionToolSourceAuthJSON struct {
+ Kind apijson.Field
+ Provider apijson.Field
+ Inject apijson.Field
+ RequiredScopes apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ToolSourceAuthOAuthConnectionToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r toolSourceAuthOAuthConnectionToolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ToolSourceAuthOAuthConnectionToolSourceAuth) implementsToolSourceAuth() {}
+
+type ToolSourceAuthOAuthConnectionToolSourceAuthKind string
+
+const (
+ ToolSourceAuthOAuthConnectionToolSourceAuthKindOAuthConnection ToolSourceAuthOAuthConnectionToolSourceAuthKind = "oauth_connection"
+)
+
+func (r ToolSourceAuthOAuthConnectionToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case ToolSourceAuthOAuthConnectionToolSourceAuthKindOAuthConnection:
+ return true
+ }
+ return false
+}
+
+type ToolSourceAuthKind string
+
+const (
+ ToolSourceAuthKindNone ToolSourceAuthKind = "none"
+ ToolSourceAuthKindAPIKey ToolSourceAuthKind = "api_key"
+ ToolSourceAuthKindOAuthExchange ToolSourceAuthKind = "oauth_exchange"
+ ToolSourceAuthKindOAuthConnection ToolSourceAuthKind = "oauth_connection"
+)
+
+func (r ToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case ToolSourceAuthKindNone, ToolSourceAuthKindAPIKey, ToolSourceAuthKindOAuthExchange, ToolSourceAuthKindOAuthConnection:
+ return true
+ }
+ return false
+}
+
+// Tool source authentication configuration. The `kind` field selects one of
+// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+type ToolSourceAuthParam struct {
+ Kind param.Field[ToolSourceAuthKind] `json:"kind" api:"required"`
+ ConnectionID param.Field[string] `json:"connectionId"`
+ // Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+ // stored client secrets and assertions.
+ Exchange param.Field[OAuthExchangeConfigUnionParam] `json:"exchange"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject param.Field[AuthInjectionUnionParam] `json:"inject"`
+ Provider param.Field[string] `json:"provider"`
+ RequiredScopes param.Field[interface{}] `json:"requiredScopes"`
+}
+
+func (r ToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
+// Tool source authentication configuration. The `kind` field selects one of
+// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+//
+// Satisfied by [ToolSourceAuthNoToolSourceAuthParam],
+// [ToolSourceAuthAPIKeyToolSourceAuthParam],
+// [ToolSourceAuthOAuthExchangeToolSourceAuthParam],
+// [ToolSourceAuthOAuthConnectionToolSourceAuthParam], [ToolSourceAuthParam].
+type ToolSourceAuthUnionParam interface {
+ implementsToolSourceAuthUnionParam()
+}
+
+type ToolSourceAuthNoToolSourceAuthParam struct {
+ Kind param.Field[ToolSourceAuthNoToolSourceAuthKind] `json:"kind" api:"required"`
+}
+
+func (r ToolSourceAuthNoToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceAuthNoToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
+type ToolSourceAuthAPIKeyToolSourceAuthParam struct {
+ ConnectionID param.Field[string] `json:"connectionId" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject param.Field[AuthInjectionUnionParam] `json:"inject" api:"required"`
+ Kind param.Field[ToolSourceAuthAPIKeyToolSourceAuthKind] `json:"kind" api:"required"`
+}
+
+func (r ToolSourceAuthAPIKeyToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceAuthAPIKeyToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
+type ToolSourceAuthOAuthExchangeToolSourceAuthParam struct {
+ // Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+ // stored client secrets and assertions.
+ Exchange param.Field[OAuthExchangeConfigUnionParam] `json:"exchange" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject param.Field[AuthInjectionUnionParam] `json:"inject" api:"required"`
+ Kind param.Field[ToolSourceAuthOAuthExchangeToolSourceAuthKind] `json:"kind" api:"required"`
+}
+
+func (r ToolSourceAuthOAuthExchangeToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceAuthOAuthExchangeToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
+type ToolSourceAuthOAuthConnectionToolSourceAuthParam struct {
+ Kind param.Field[ToolSourceAuthOAuthConnectionToolSourceAuthKind] `json:"kind" api:"required"`
+ Provider param.Field[string] `json:"provider" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject param.Field[AuthInjectionUnionParam] `json:"inject"`
+ RequiredScopes param.Field[[]string] `json:"requiredScopes"`
+}
+
+func (r ToolSourceAuthOAuthConnectionToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolSourceAuthOAuthConnectionToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
+type ToolNewParams struct {
+ Tool ToolNewParamsToolUnion `json:"tool" api:"required"`
+}
+
+func (r ToolNewParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r.Tool)
+}
+
+type ToolNewParamsTool struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Type param.Field[ToolNewParamsToolType] `json:"type" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ Execution param.Field[interface{}] `json:"execution"`
+ Tools param.Field[interface{}] `json:"tools"`
+ URL param.Field[string] `json:"url"`
+}
+
+func (r ToolNewParamsTool) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolNewParamsTool) implementsToolNewParamsToolUnion() {}
+
+// Satisfied by [ToolNewParamsToolCreateHTTPToolSourceRequest],
+// [ToolNewParamsToolCreateMcpToolSourceRequest], [ToolNewParamsTool].
+type ToolNewParamsToolUnion interface {
+ implementsToolNewParamsToolUnion()
+}
+
+type ToolNewParamsToolCreateHTTPToolSourceRequest struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
+ Type param.Field[ToolNewParamsToolCreateHTTPToolSourceRequestType] `json:"type" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ // HTTP tool execution retry and timeout policy.
+ Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolNewParamsToolCreateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolNewParamsToolCreateHTTPToolSourceRequest) implementsToolNewParamsToolUnion() {}
+
+type ToolNewParamsToolCreateHTTPToolSourceRequestType string
+
+const (
+ ToolNewParamsToolCreateHTTPToolSourceRequestTypeHTTP ToolNewParamsToolCreateHTTPToolSourceRequestType = "http"
+)
+
+func (r ToolNewParamsToolCreateHTTPToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolNewParamsToolCreateHTTPToolSourceRequestTypeHTTP:
+ return true
+ }
+ return false
+}
+
+type ToolNewParamsToolCreateMcpToolSourceRequest struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Type param.Field[ToolNewParamsToolCreateMcpToolSourceRequestType] `json:"type" api:"required"`
+ URL param.Field[string] `json:"url" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ // MCP discovery and execution retry/timeout policy.
+ Execution param.Field[McpToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolNewParamsToolCreateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolNewParamsToolCreateMcpToolSourceRequest) implementsToolNewParamsToolUnion() {}
+
+type ToolNewParamsToolCreateMcpToolSourceRequestType string
+
+const (
+ ToolNewParamsToolCreateMcpToolSourceRequestTypeMcp ToolNewParamsToolCreateMcpToolSourceRequestType = "mcp"
+)
+
+func (r ToolNewParamsToolCreateMcpToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolNewParamsToolCreateMcpToolSourceRequestTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolNewParamsToolType string
+
+const (
+ ToolNewParamsToolTypeHTTP ToolNewParamsToolType = "http"
+ ToolNewParamsToolTypeMcp ToolNewParamsToolType = "mcp"
+)
+
+func (r ToolNewParamsToolType) IsKnown() bool {
+ switch r {
+ case ToolNewParamsToolTypeHTTP, ToolNewParamsToolTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolUpdateParams struct {
+ Tool ToolUpdateParamsToolUnion `json:"tool" api:"required"`
+}
+
+func (r ToolUpdateParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r.Tool)
+}
+
+type ToolUpdateParamsTool struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Type param.Field[ToolUpdateParamsToolType] `json:"type" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ Execution param.Field[interface{}] `json:"execution"`
+ Tools param.Field[interface{}] `json:"tools"`
+ URL param.Field[string] `json:"url"`
+}
+
+func (r ToolUpdateParamsTool) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolUpdateParamsTool) implementsToolUpdateParamsToolUnion() {}
+
+// Satisfied by [ToolUpdateParamsToolUpdateHTTPToolSourceRequest],
+// [ToolUpdateParamsToolUpdateMcpToolSourceRequest], [ToolUpdateParamsTool].
+type ToolUpdateParamsToolUnion interface {
+ implementsToolUpdateParamsToolUnion()
+}
+
+type ToolUpdateParamsToolUpdateHTTPToolSourceRequest struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
+ Type param.Field[ToolUpdateParamsToolUpdateHTTPToolSourceRequestType] `json:"type" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ // HTTP tool execution retry and timeout policy.
+ Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolUpdateParamsToolUpdateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolUpdateParamsToolUpdateHTTPToolSourceRequest) implementsToolUpdateParamsToolUnion() {}
+
+type ToolUpdateParamsToolUpdateHTTPToolSourceRequestType string
+
+const (
+ ToolUpdateParamsToolUpdateHTTPToolSourceRequestTypeHTTP ToolUpdateParamsToolUpdateHTTPToolSourceRequestType = "http"
+)
+
+func (r ToolUpdateParamsToolUpdateHTTPToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolUpdateParamsToolUpdateHTTPToolSourceRequestTypeHTTP:
+ return true
+ }
+ return false
+}
+
+type ToolUpdateParamsToolUpdateMcpToolSourceRequest struct {
+ // Tool source authentication configuration. The `kind` field selects one of
+ // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
+ Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
+ Namespace param.Field[string] `json:"namespace" api:"required"`
+ Type param.Field[ToolUpdateParamsToolUpdateMcpToolSourceRequestType] `json:"type" api:"required"`
+ URL param.Field[string] `json:"url" api:"required"`
+ Approval param.Field[ToolApprovalMode] `json:"approval"`
+ Enabled param.Field[bool] `json:"enabled"`
+ // MCP discovery and execution retry/timeout policy.
+ Execution param.Field[McpToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolUpdateParamsToolUpdateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolUpdateParamsToolUpdateMcpToolSourceRequest) implementsToolUpdateParamsToolUnion() {}
+
+type ToolUpdateParamsToolUpdateMcpToolSourceRequestType string
+
+const (
+ ToolUpdateParamsToolUpdateMcpToolSourceRequestTypeMcp ToolUpdateParamsToolUpdateMcpToolSourceRequestType = "mcp"
+)
+
+func (r ToolUpdateParamsToolUpdateMcpToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolUpdateParamsToolUpdateMcpToolSourceRequestTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolUpdateParamsToolType string
+
+const (
+ ToolUpdateParamsToolTypeHTTP ToolUpdateParamsToolType = "http"
+ ToolUpdateParamsToolTypeMcp ToolUpdateParamsToolType = "mcp"
+)
+
+func (r ToolUpdateParamsToolType) IsKnown() bool {
+ switch r {
+ case ToolUpdateParamsToolTypeHTTP, ToolUpdateParamsToolTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolListParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [ToolListParams]'s query parameters as `url.Values`.
+func (r ToolListParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
diff --git a/tool_test.go b/tool_test.go
index 5683e36..001b5fe 100644
--- a/tool_test.go
+++ b/tool_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestToolListForAgent(t *testing.T) {
+func TestToolNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,7 +25,213 @@ func TestToolListForAgent(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Tools.ListForAgent(context.TODO(), "agent_abc123")
+ _, err := client.Tools.New(
+ context.TODO(),
+ "fleet_abc123",
+ cercago.ToolNewParams{
+ Tool: cercago.ToolNewParamsToolCreateHTTPToolSourceRequest{
+ Auth: cercago.F[cercago.ToolSourceAuthUnionParam](cercago.ToolSourceAuthNoToolSourceAuthParam{
+ Kind: cercago.F(cercago.ToolSourceAuthNoToolSourceAuthKindNone),
+ }),
+ Namespace: cercago.F("docs"),
+ Tools: cercago.F([]cercago.HTTPToolDefinitionParam{{
+ Description: cercago.F("Search documents"),
+ Endpoint: cercago.F(cercago.HTTPEndpointParam{
+ Method: cercago.F(cercago.HTTPEndpointMethodGet),
+ URL: cercago.F("https://docs.example.com/search"),
+ Body: cercago.F(cercago.HTTPEndpointBodyJsonParams),
+ Headers: cercago.F(map[string]string{
+ "foo": "string",
+ }),
+ Path: cercago.F(map[string]string{
+ "foo": "params.query",
+ }),
+ Query: cercago.F(map[string]string{
+ "foo": "params.query",
+ }),
+ }),
+ InputSchema: cercago.F(map[string]interface{}{
+ "type": "bar",
+ }),
+ Name: cercago.F("search"),
+ Approval: cercago.F(cercago.ToolApprovalModeAlways),
+ Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
+ IdempotencyKeyHeader: cercago.F("idempotencyKeyHeader"),
+ MaxAttempts: cercago.F(3.000000),
+ RetryMode: cercago.F(cercago.HTTPToolExecutionPolicyRetryModeSafeOnly),
+ TimeoutMs: cercago.F(10000.000000),
+ }),
+ Response: cercago.F(cercago.ResponseNormalizationHintParam{
+ Mode: cercago.F(cercago.ResponseNormalizationHintModeAuto),
+ }),
+ }}),
+ Type: cercago.F(cercago.ToolNewParamsToolCreateHTTPToolSourceRequestTypeHTTP),
+ Approval: cercago.F(cercago.ToolApprovalModeAlways),
+ Enabled: cercago.F(true),
+ Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
+ IdempotencyKeyHeader: cercago.F("idempotencyKeyHeader"),
+ MaxAttempts: cercago.F(3.000000),
+ RetryMode: cercago.F(cercago.HTTPToolExecutionPolicyRetryModeSafeOnly),
+ TimeoutMs: cercago.F(10000.000000),
+ }),
+ },
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestToolGet(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Tools.Get(
+ context.TODO(),
+ "fleet_abc123",
+ "toolsrc_abc123",
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestToolUpdateWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Tools.Update(
+ context.TODO(),
+ "fleet_abc123",
+ "toolsrc_abc123",
+ cercago.ToolUpdateParams{
+ Tool: cercago.ToolUpdateParamsToolUpdateHTTPToolSourceRequest{
+ Auth: cercago.F[cercago.ToolSourceAuthUnionParam](cercago.ToolSourceAuthNoToolSourceAuthParam{
+ Kind: cercago.F(cercago.ToolSourceAuthNoToolSourceAuthKindNone),
+ }),
+ Namespace: cercago.F("docs"),
+ Tools: cercago.F([]cercago.HTTPToolDefinitionParam{{
+ Description: cercago.F("Search documents"),
+ Endpoint: cercago.F(cercago.HTTPEndpointParam{
+ Method: cercago.F(cercago.HTTPEndpointMethodGet),
+ URL: cercago.F("https://docs.example.com/search"),
+ Body: cercago.F(cercago.HTTPEndpointBodyJsonParams),
+ Headers: cercago.F(map[string]string{
+ "foo": "string",
+ }),
+ Path: cercago.F(map[string]string{
+ "foo": "params.query",
+ }),
+ Query: cercago.F(map[string]string{
+ "foo": "params.query",
+ }),
+ }),
+ InputSchema: cercago.F(map[string]interface{}{
+ "type": "bar",
+ }),
+ Name: cercago.F("search"),
+ Approval: cercago.F(cercago.ToolApprovalModeAlways),
+ Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
+ IdempotencyKeyHeader: cercago.F("idempotencyKeyHeader"),
+ MaxAttempts: cercago.F(3.000000),
+ RetryMode: cercago.F(cercago.HTTPToolExecutionPolicyRetryModeSafeOnly),
+ TimeoutMs: cercago.F(10000.000000),
+ }),
+ Response: cercago.F(cercago.ResponseNormalizationHintParam{
+ Mode: cercago.F(cercago.ResponseNormalizationHintModeAuto),
+ }),
+ }}),
+ Type: cercago.F(cercago.ToolUpdateParamsToolUpdateHTTPToolSourceRequestTypeHTTP),
+ Approval: cercago.F(cercago.ToolApprovalModeAlways),
+ Enabled: cercago.F(true),
+ Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
+ IdempotencyKeyHeader: cercago.F("idempotencyKeyHeader"),
+ MaxAttempts: cercago.F(3.000000),
+ RetryMode: cercago.F(cercago.HTTPToolExecutionPolicyRetryModeSafeOnly),
+ TimeoutMs: cercago.F(10000.000000),
+ }),
+ },
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestToolListWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ _, err := client.Tools.List(
+ context.TODO(),
+ "fleet_abc123",
+ cercago.ToolListParams{
+ Cursor: cercago.F("cursor_abc123"),
+ Limit: cercago.F("20"),
+ },
+ )
+ if err != nil {
+ var apierr *cercago.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestToolDelete(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := cercago.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAPIKey("My API Key"),
+ )
+ err := client.Tools.Delete(
+ context.TODO(),
+ "fleet_abc123",
+ "toolsrc_abc123",
+ )
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
diff --git a/toolsource.go b/toolsource.go
deleted file mode 100644
index ddaeaff..0000000
--- a/toolsource.go
+++ /dev/null
@@ -1,665 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago
-
-import (
- "context"
- "errors"
- "fmt"
- "net/http"
- "net/url"
- "reflect"
- "slices"
-
- "github.com/matrices/cerca-go/internal/apijson"
- "github.com/matrices/cerca-go/internal/apiquery"
- "github.com/matrices/cerca-go/internal/param"
- "github.com/matrices/cerca-go/internal/requestconfig"
- "github.com/matrices/cerca-go/option"
- "github.com/matrices/cerca-go/packages/pagination"
- "github.com/tidwall/gjson"
-)
-
-// ToolSourceService contains methods and other services that help with interacting
-// with the cerca API.
-//
-// Note, unlike clients, this service does not read variables from the environment
-// automatically. You should not instantiate this service directly, and instead use
-// the [NewToolSourceService] method instead.
-type ToolSourceService struct {
- Options []option.RequestOption
-}
-
-// NewToolSourceService generates a new service that applies the given options to
-// each request. These options are applied after the parent client's options (if
-// there is one), and before any request-specific options.
-func NewToolSourceService(opts ...option.RequestOption) (r *ToolSourceService) {
- r = &ToolSourceService{}
- r.Options = opts
- return
-}
-
-func (r *ToolSourceService) New(ctx context.Context, fleetID string, body ToolSourceNewParams, opts ...option.RequestOption) (res *ToolSource, err error) {
- opts = slices.Concat(r.Options, opts)
- if fleetID == "" {
- err = errors.New("missing required fleetId parameter")
- return nil, err
- }
- path := fmt.Sprintf("fleets/%s/tool-sources", fleetID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
- return res, err
-}
-
-func (r *ToolSourceService) Get(ctx context.Context, fleetID string, sourceID string, opts ...option.RequestOption) (res *ToolSource, err error) {
- opts = slices.Concat(r.Options, opts)
- if fleetID == "" {
- err = errors.New("missing required fleetId parameter")
- return nil, err
- }
- if sourceID == "" {
- err = errors.New("missing required sourceId parameter")
- return nil, err
- }
- path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-func (r *ToolSourceService) Update(ctx context.Context, fleetID string, sourceID string, body ToolSourceUpdateParams, opts ...option.RequestOption) (res *ToolSource, err error) {
- opts = slices.Concat(r.Options, opts)
- if fleetID == "" {
- err = errors.New("missing required fleetId parameter")
- return nil, err
- }
- if sourceID == "" {
- err = errors.New("missing required sourceId parameter")
- return nil, err
- }
- path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
- return res, err
-}
-
-func (r *ToolSourceService) List(ctx context.Context, fleetID string, query ToolSourceListParams, opts ...option.RequestOption) (res *pagination.SourcesCursorPage[ToolSource], err error) {
- var raw *http.Response
- opts = slices.Concat(r.Options, opts)
- opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
- if fleetID == "" {
- err = errors.New("missing required fleetId parameter")
- return nil, err
- }
- path := fmt.Sprintf("fleets/%s/tool-sources", fleetID)
- cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
- if err != nil {
- return nil, err
- }
- err = cfg.Execute()
- if err != nil {
- return nil, err
- }
- res.SetPageConfig(cfg, raw)
- return res, nil
-}
-
-func (r *ToolSourceService) ListAutoPaging(ctx context.Context, fleetID string, query ToolSourceListParams, opts ...option.RequestOption) *pagination.SourcesCursorPageAutoPager[ToolSource] {
- return pagination.NewSourcesCursorPageAutoPager(r.List(ctx, fleetID, query, opts...))
-}
-
-func (r *ToolSourceService) Delete(ctx context.Context, fleetID string, sourceID string, opts ...option.RequestOption) (err error) {
- opts = slices.Concat(r.Options, opts)
- opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
- if fleetID == "" {
- err = errors.New("missing required fleetId parameter")
- return err
- }
- if sourceID == "" {
- err = errors.New("missing required sourceId parameter")
- return err
- }
- path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
- return err
-}
-
-func (r *ToolSourceService) ListForAgent(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ToolSourceListForAgentResponse, err error) {
- opts = slices.Concat(r.Options, opts)
- if agentID == "" {
- err = errors.New("missing required agentId parameter")
- return nil, err
- }
- path := fmt.Sprintf("agents/%s/tool-sources", agentID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
-}
-
-type HTTPToolDefinition map[string]interface{}
-
-type HTTPToolDefinitionParam map[string]interface{}
-
-type HTTPToolExecutionPolicy map[string]interface{}
-
-type HTTPToolExecutionPolicyParam map[string]interface{}
-
-type HTTPToolSource struct {
- ID string `json:"id" api:"required"`
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth ToolSourceAuth `json:"auth" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- FleetID string `json:"fleetId" api:"required"`
- Namespace string `json:"namespace" api:"required"`
- Tools []HTTPToolDefinition `json:"tools" api:"required"`
- Type HTTPToolSourceType `json:"type" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Version float64 `json:"version" api:"required"`
- Approval ToolApprovalMode `json:"approval"`
- // HTTP tool execution retry and timeout policy.
- Execution HTTPToolExecutionPolicy `json:"execution"`
- JSON httpToolSourceJSON `json:"-"`
-}
-
-// httpToolSourceJSON contains the JSON metadata for the struct [HTTPToolSource]
-type httpToolSourceJSON struct {
- ID apijson.Field
- Auth apijson.Field
- CreatedAt apijson.Field
- Enabled apijson.Field
- FleetID apijson.Field
- Namespace apijson.Field
- Tools apijson.Field
- Type apijson.Field
- UpdatedAt apijson.Field
- Version apijson.Field
- Approval apijson.Field
- Execution apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *HTTPToolSource) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r httpToolSourceJSON) RawJSON() string {
- return r.raw
-}
-
-func (r HTTPToolSource) implementsToolSource() {}
-
-type HTTPToolSourceType string
-
-const (
- HTTPToolSourceTypeHTTP HTTPToolSourceType = "http"
-)
-
-func (r HTTPToolSourceType) IsKnown() bool {
- switch r {
- case HTTPToolSourceTypeHTTP:
- return true
- }
- return false
-}
-
-type McpToolExecutionPolicy map[string]interface{}
-
-type McpToolExecutionPolicyParam map[string]interface{}
-
-type McpToolSource struct {
- ID string `json:"id" api:"required"`
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth ToolSourceAuth `json:"auth" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- FleetID string `json:"fleetId" api:"required"`
- Namespace string `json:"namespace" api:"required"`
- Type McpToolSourceType `json:"type" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- URL string `json:"url" api:"required"`
- Version float64 `json:"version" api:"required"`
- Approval ToolApprovalMode `json:"approval"`
- // MCP discovery and execution retry/timeout policy.
- Execution McpToolExecutionPolicy `json:"execution"`
- JSON mcpToolSourceJSON `json:"-"`
-}
-
-// mcpToolSourceJSON contains the JSON metadata for the struct [McpToolSource]
-type mcpToolSourceJSON struct {
- ID apijson.Field
- Auth apijson.Field
- CreatedAt apijson.Field
- Enabled apijson.Field
- FleetID apijson.Field
- Namespace apijson.Field
- Type apijson.Field
- UpdatedAt apijson.Field
- URL apijson.Field
- Version apijson.Field
- Approval apijson.Field
- Execution apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *McpToolSource) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r mcpToolSourceJSON) RawJSON() string {
- return r.raw
-}
-
-func (r McpToolSource) implementsToolSource() {}
-
-type McpToolSourceType string
-
-const (
- McpToolSourceTypeMcp McpToolSourceType = "mcp"
-)
-
-func (r McpToolSourceType) IsKnown() bool {
- switch r {
- case McpToolSourceTypeMcp:
- return true
- }
- return false
-}
-
-type ToolApprovalMode string
-
-const (
- ToolApprovalModeAlways ToolApprovalMode = "always"
- ToolApprovalModeNever ToolApprovalMode = "never"
-)
-
-func (r ToolApprovalMode) IsKnown() bool {
- switch r {
- case ToolApprovalModeAlways, ToolApprovalModeNever:
- return true
- }
- return false
-}
-
-type ToolSource struct {
- ID string `json:"id" api:"required"`
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth ToolSourceAuth `json:"auth" api:"required"`
- CreatedAt string `json:"createdAt" api:"required"`
- Enabled bool `json:"enabled" api:"required"`
- FleetID string `json:"fleetId" api:"required"`
- Namespace string `json:"namespace" api:"required"`
- Type ToolSourceType `json:"type" api:"required"`
- UpdatedAt string `json:"updatedAt" api:"required"`
- Version float64 `json:"version" api:"required"`
- Approval ToolApprovalMode `json:"approval"`
- // This field can have the runtime type of [HTTPToolExecutionPolicy],
- // [McpToolExecutionPolicy].
- Execution interface{} `json:"execution"`
- // This field can have the runtime type of [[]HTTPToolDefinition].
- Tools interface{} `json:"tools"`
- URL string `json:"url"`
- JSON toolSourceJSON `json:"-"`
- union ToolSourceUnion
-}
-
-// toolSourceJSON contains the JSON metadata for the struct [ToolSource]
-type toolSourceJSON struct {
- ID apijson.Field
- Auth apijson.Field
- CreatedAt apijson.Field
- Enabled apijson.Field
- FleetID apijson.Field
- Namespace apijson.Field
- Type apijson.Field
- UpdatedAt apijson.Field
- Version apijson.Field
- Approval apijson.Field
- Execution apijson.Field
- Tools apijson.Field
- URL apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r toolSourceJSON) RawJSON() string {
- return r.raw
-}
-
-func (r *ToolSource) UnmarshalJSON(data []byte) (err error) {
- *r = ToolSource{}
- err = apijson.UnmarshalRoot(data, &r.union)
- if err != nil {
- return err
- }
- return apijson.Port(r.union, &r)
-}
-
-// AsUnion returns a [ToolSourceUnion] interface which you can cast to the specific
-// types for more type safety.
-//
-// Possible runtime types of the union are [HTTPToolSource], [McpToolSource].
-func (r ToolSource) AsUnion() ToolSourceUnion {
- return r.union
-}
-
-// Union satisfied by [HTTPToolSource] or [McpToolSource].
-type ToolSourceUnion interface {
- implementsToolSource()
-}
-
-func init() {
- apijson.RegisterUnion(
- reflect.TypeOf((*ToolSourceUnion)(nil)).Elem(),
- "type",
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(HTTPToolSource{}),
- DiscriminatorValue: "http",
- },
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(McpToolSource{}),
- DiscriminatorValue: "mcp",
- },
- )
-}
-
-type ToolSourceType string
-
-const (
- ToolSourceTypeHTTP ToolSourceType = "http"
- ToolSourceTypeMcp ToolSourceType = "mcp"
-)
-
-func (r ToolSourceType) IsKnown() bool {
- switch r {
- case ToolSourceTypeHTTP, ToolSourceTypeMcp:
- return true
- }
- return false
-}
-
-type ToolSourceAuth map[string]interface{}
-
-type ToolSourceAuthParam map[string]interface{}
-
-type ToolSourceListForAgentResponse struct {
- Cursor string `json:"cursor" api:"required,nullable"`
- HasMore bool `json:"hasMore" api:"required"`
- Sources []ToolSource `json:"sources" api:"required"`
- JSON toolSourceListForAgentResponseJSON `json:"-"`
-}
-
-// toolSourceListForAgentResponseJSON contains the JSON metadata for the struct
-// [ToolSourceListForAgentResponse]
-type toolSourceListForAgentResponseJSON struct {
- Cursor apijson.Field
- HasMore apijson.Field
- Sources apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ToolSourceListForAgentResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r toolSourceListForAgentResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type ToolSourceNewParams struct {
- Source ToolSourceNewParamsSourceUnion `json:"source" api:"required"`
-}
-
-func (r ToolSourceNewParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r.Source)
-}
-
-type ToolSourceNewParamsSource struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[ToolSourceNewParamsSourceType] `json:"type" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- Execution param.Field[interface{}] `json:"execution"`
- Tools param.Field[interface{}] `json:"tools"`
- URL param.Field[string] `json:"url"`
-}
-
-func (r ToolSourceNewParamsSource) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceNewParamsSource) implementsToolSourceNewParamsSourceUnion() {}
-
-// Satisfied by [ToolSourceNewParamsSourceCreateHTTPToolSourceRequest],
-// [ToolSourceNewParamsSourceCreateMcpToolSourceRequest],
-// [ToolSourceNewParamsSource].
-type ToolSourceNewParamsSourceUnion interface {
- implementsToolSourceNewParamsSourceUnion()
-}
-
-type ToolSourceNewParamsSourceCreateHTTPToolSourceRequest struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
- Type param.Field[ToolSourceNewParamsSourceCreateHTTPToolSourceRequestType] `json:"type" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- // HTTP tool execution retry and timeout policy.
- Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
- ExtraFields map[string]interface{} `json:"-,extras"`
-}
-
-func (r ToolSourceNewParamsSourceCreateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceNewParamsSourceCreateHTTPToolSourceRequest) implementsToolSourceNewParamsSourceUnion() {
-}
-
-type ToolSourceNewParamsSourceCreateHTTPToolSourceRequestType string
-
-const (
- ToolSourceNewParamsSourceCreateHTTPToolSourceRequestTypeHTTP ToolSourceNewParamsSourceCreateHTTPToolSourceRequestType = "http"
-)
-
-func (r ToolSourceNewParamsSourceCreateHTTPToolSourceRequestType) IsKnown() bool {
- switch r {
- case ToolSourceNewParamsSourceCreateHTTPToolSourceRequestTypeHTTP:
- return true
- }
- return false
-}
-
-type ToolSourceNewParamsSourceCreateMcpToolSourceRequest struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[ToolSourceNewParamsSourceCreateMcpToolSourceRequestType] `json:"type" api:"required"`
- URL param.Field[string] `json:"url" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- // MCP discovery and execution retry/timeout policy.
- Execution param.Field[McpToolExecutionPolicyParam] `json:"execution"`
- ExtraFields map[string]interface{} `json:"-,extras"`
-}
-
-func (r ToolSourceNewParamsSourceCreateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceNewParamsSourceCreateMcpToolSourceRequest) implementsToolSourceNewParamsSourceUnion() {
-}
-
-type ToolSourceNewParamsSourceCreateMcpToolSourceRequestType string
-
-const (
- ToolSourceNewParamsSourceCreateMcpToolSourceRequestTypeMcp ToolSourceNewParamsSourceCreateMcpToolSourceRequestType = "mcp"
-)
-
-func (r ToolSourceNewParamsSourceCreateMcpToolSourceRequestType) IsKnown() bool {
- switch r {
- case ToolSourceNewParamsSourceCreateMcpToolSourceRequestTypeMcp:
- return true
- }
- return false
-}
-
-type ToolSourceNewParamsSourceType string
-
-const (
- ToolSourceNewParamsSourceTypeHTTP ToolSourceNewParamsSourceType = "http"
- ToolSourceNewParamsSourceTypeMcp ToolSourceNewParamsSourceType = "mcp"
-)
-
-func (r ToolSourceNewParamsSourceType) IsKnown() bool {
- switch r {
- case ToolSourceNewParamsSourceTypeHTTP, ToolSourceNewParamsSourceTypeMcp:
- return true
- }
- return false
-}
-
-type ToolSourceUpdateParams struct {
- Source ToolSourceUpdateParamsSourceUnion `json:"source" api:"required"`
-}
-
-func (r ToolSourceUpdateParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r.Source)
-}
-
-type ToolSourceUpdateParamsSource struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[ToolSourceUpdateParamsSourceType] `json:"type" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- Execution param.Field[interface{}] `json:"execution"`
- Tools param.Field[interface{}] `json:"tools"`
- URL param.Field[string] `json:"url"`
-}
-
-func (r ToolSourceUpdateParamsSource) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceUpdateParamsSource) implementsToolSourceUpdateParamsSourceUnion() {}
-
-// Satisfied by [ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest],
-// [ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequest],
-// [ToolSourceUpdateParamsSource].
-type ToolSourceUpdateParamsSourceUnion interface {
- implementsToolSourceUpdateParamsSourceUnion()
-}
-
-type ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
- Type param.Field[ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestType] `json:"type" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- // HTTP tool execution retry and timeout policy.
- Execution param.Field[HTTPToolExecutionPolicyParam] `json:"execution"`
- ExtraFields map[string]interface{} `json:"-,extras"`
-}
-
-func (r ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest) implementsToolSourceUpdateParamsSourceUnion() {
-}
-
-type ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestType string
-
-const (
- ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestTypeHTTP ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestType = "http"
-)
-
-func (r ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestType) IsKnown() bool {
- switch r {
- case ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestTypeHTTP:
- return true
- }
- return false
-}
-
-type ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequest struct {
- // Tool source authentication configuration. The `kind` field selects one of
- // `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
- Auth param.Field[ToolSourceAuthParam] `json:"auth" api:"required"`
- Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestType] `json:"type" api:"required"`
- URL param.Field[string] `json:"url" api:"required"`
- Approval param.Field[ToolApprovalMode] `json:"approval"`
- Enabled param.Field[bool] `json:"enabled"`
- // MCP discovery and execution retry/timeout policy.
- Execution param.Field[McpToolExecutionPolicyParam] `json:"execution"`
- ExtraFields map[string]interface{} `json:"-,extras"`
-}
-
-func (r ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequest) implementsToolSourceUpdateParamsSourceUnion() {
-}
-
-type ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestType string
-
-const (
- ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestTypeMcp ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestType = "mcp"
-)
-
-func (r ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestType) IsKnown() bool {
- switch r {
- case ToolSourceUpdateParamsSourceUpdateMcpToolSourceRequestTypeMcp:
- return true
- }
- return false
-}
-
-type ToolSourceUpdateParamsSourceType string
-
-const (
- ToolSourceUpdateParamsSourceTypeHTTP ToolSourceUpdateParamsSourceType = "http"
- ToolSourceUpdateParamsSourceTypeMcp ToolSourceUpdateParamsSourceType = "mcp"
-)
-
-func (r ToolSourceUpdateParamsSourceType) IsKnown() bool {
- switch r {
- case ToolSourceUpdateParamsSourceTypeHTTP, ToolSourceUpdateParamsSourceTypeMcp:
- return true
- }
- return false
-}
-
-type ToolSourceListParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
-}
-
-// URLQuery serializes [ToolSourceListParams]'s query parameters as `url.Values`.
-func (r ToolSourceListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
diff --git a/toolsource_test.go b/toolsource_test.go
deleted file mode 100644
index e8190e6..0000000
--- a/toolsource_test.go
+++ /dev/null
@@ -1,212 +0,0 @@
-// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-package cercago_test
-
-import (
- "context"
- "errors"
- "os"
- "testing"
-
- "github.com/matrices/cerca-go"
- "github.com/matrices/cerca-go/internal/testutil"
- "github.com/matrices/cerca-go/option"
-)
-
-func TestToolSourceNewWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.ToolSources.New(
- context.TODO(),
- "fleet_abc123",
- cercago.ToolSourceNewParams{
- Source: cercago.ToolSourceNewParamsSourceCreateHTTPToolSourceRequest{
- Auth: cercago.F(cercago.ToolSourceAuthParam{
- "kind": "bar",
- }),
- Namespace: cercago.F("docs"),
- Tools: cercago.F([]cercago.HTTPToolDefinitionParam{{
- "name": "bar",
- "description": "bar",
- "inputSchema": "bar",
- "endpoint": "bar",
- }}),
- Type: cercago.F(cercago.ToolSourceNewParamsSourceCreateHTTPToolSourceRequestTypeHTTP),
- Approval: cercago.F(cercago.ToolApprovalModeAlways),
- Enabled: cercago.F(true),
- Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
- "timeoutMs": "bar",
- "maxAttempts": "bar",
- "retryMode": "bar",
- }),
- },
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestToolSourceGet(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.ToolSources.Get(
- context.TODO(),
- "fleet_abc123",
- "toolsrc_abc123",
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestToolSourceUpdateWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.ToolSources.Update(
- context.TODO(),
- "fleet_abc123",
- "toolsrc_abc123",
- cercago.ToolSourceUpdateParams{
- Source: cercago.ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequest{
- Auth: cercago.F(cercago.ToolSourceAuthParam{
- "kind": "bar",
- }),
- Namespace: cercago.F("docs"),
- Tools: cercago.F([]cercago.HTTPToolDefinitionParam{{
- "name": "bar",
- "description": "bar",
- "inputSchema": "bar",
- "endpoint": "bar",
- }}),
- Type: cercago.F(cercago.ToolSourceUpdateParamsSourceUpdateHTTPToolSourceRequestTypeHTTP),
- Approval: cercago.F(cercago.ToolApprovalModeAlways),
- Enabled: cercago.F(true),
- Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
- "timeoutMs": "bar",
- "maxAttempts": "bar",
- "retryMode": "bar",
- }),
- },
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestToolSourceListWithOptionalParams(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.ToolSources.List(
- context.TODO(),
- "fleet_abc123",
- cercago.ToolSourceListParams{
- Cursor: cercago.F("cursor_abc123"),
- Limit: cercago.F("20"),
- },
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestToolSourceDelete(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- err := client.ToolSources.Delete(
- context.TODO(),
- "fleet_abc123",
- "toolsrc_abc123",
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestToolSourceListForAgent(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.ToolSources.ListForAgent(context.TODO(), "agent_abc123")
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/usage_test.go b/usage_test.go
index f5fc7c5..801cd44 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -28,7 +28,7 @@ func TestUsage(t *testing.T) {
context.TODO(),
"agent_abc123",
cercago.ThreadNewParams{
- UserMessage: cercago.F("What's on my calendar today?"),
+ Message: cercago.F("What's on my calendar today?"),
},
)
if err != nil {
diff --git a/webhook.go b/webhook.go
index b8d0876..d7a71d0 100644
--- a/webhook.go
+++ b/webhook.go
@@ -37,6 +37,7 @@ func NewWebhookService(opts ...option.RequestOption) (r *WebhookService) {
return
}
+// Webhooks
func (r *WebhookService) New(ctx context.Context, fleetID string, body WebhookNewParams, opts ...option.RequestOption) (res *WebhookSubscriptionCreated, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -48,6 +49,7 @@ func (r *WebhookService) New(ctx context.Context, fleetID string, body WebhookNe
return res, err
}
+// Webhook
func (r *WebhookService) Get(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookSubscription, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -63,6 +65,7 @@ func (r *WebhookService) Get(ctx context.Context, fleetID string, webhookID stri
return res, err
}
+// Webhook
func (r *WebhookService) Update(ctx context.Context, fleetID string, webhookID string, body WebhookUpdateParams, opts ...option.RequestOption) (res *WebhookSubscription, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -78,6 +81,7 @@ func (r *WebhookService) Update(ctx context.Context, fleetID string, webhookID s
return res, err
}
+// Webhooks
func (r *WebhookService) List(ctx context.Context, fleetID string, query WebhookListParams, opts ...option.RequestOption) (res *pagination.SubscriptionsCursorPage[WebhookSubscription], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -99,10 +103,12 @@ func (r *WebhookService) List(ctx context.Context, fleetID string, query Webhook
return res, nil
}
+// Webhooks
func (r *WebhookService) ListAutoPaging(ctx context.Context, fleetID string, query WebhookListParams, opts ...option.RequestOption) *pagination.SubscriptionsCursorPageAutoPager[WebhookSubscription] {
return pagination.NewSubscriptionsCursorPageAutoPager(r.List(ctx, fleetID, query, opts...))
}
+// Webhook
func (r *WebhookService) Delete(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
@@ -119,6 +125,7 @@ func (r *WebhookService) Delete(ctx context.Context, fleetID string, webhookID s
return err
}
+// Rotate
func (r *WebhookService) Rotate(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookSubscriptionCreated, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -134,6 +141,7 @@ func (r *WebhookService) Rotate(ctx context.Context, fleetID string, webhookID s
return res, err
}
+// Test
func (r *WebhookService) Test(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookTestResponse, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
From 276aabaf2a81dcf3a2ea9c41d64521005cc029bf Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 20:28:38 +0000
Subject: [PATCH 13/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index c4eee12..3204ef5 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-faba937c111404b92c6ad3e74fc0184ceee1ac22171c59c191f0ada6e90b8e18.yml
openapi_spec_hash: dc483f9e464f4ba657bab48df3fa09fe
-config_hash: 760e5624c524327bcfb49e54b9e3a6e2
+config_hash: 48e1e2cb9529b83aa8ff8468103a681b
From 1993ace6337df84d6f5f898493a3f63af7ad14e7 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 20:35:24 +0000
Subject: [PATCH 14/29] feat(api): api update
---
.stats.yml | 6 +++---
agent.go | 18 +++++++++---------
approvalgrant.go | 10 +++++-----
approvalrequest.go | 6 +++---
auth.go | 6 +++---
connection.go | 14 +++++++-------
context.go | 14 +++++++-------
event.go | 12 ++++++------
model.go | 2 +-
oauth.go | 2 +-
sandbox.go | 6 +++---
schedule.go | 10 +++++-----
thread.go | 10 +++++-----
tool.go | 12 ++++++------
webhook.go | 16 ++++++++--------
15 files changed, 72 insertions(+), 72 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index 3204ef5..450db1f 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-faba937c111404b92c6ad3e74fc0184ceee1ac22171c59c191f0ada6e90b8e18.yml
-openapi_spec_hash: dc483f9e464f4ba657bab48df3fa09fe
-config_hash: 48e1e2cb9529b83aa8ff8468103a681b
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-fdb0c332c7ecd66c4dbed402d9b5a188e6924adc9791402ebd7aabca591c5ce5.yml
+openapi_spec_hash: 65f7de0df776dc1df073cca2154a3684
+config_hash: 760e5624c524327bcfb49e54b9e3a6e2
diff --git a/agent.go b/agent.go
index ff02137..12e8fbc 100644
--- a/agent.go
+++ b/agent.go
@@ -40,7 +40,7 @@ func NewAgentService(opts ...option.RequestOption) (r *AgentService) {
return
}
-// Agents
+// Create agent
func (r *AgentService) New(ctx context.Context, body AgentNewParams, opts ...option.RequestOption) (res *Agent, err error) {
opts = slices.Concat(r.Options, opts)
path := "agents"
@@ -48,7 +48,7 @@ func (r *AgentService) New(ctx context.Context, body AgentNewParams, opts ...opt
return res, err
}
-// Agent
+// Retrieve agent
func (r *AgentService) Get(ctx context.Context, agentID string, opts ...option.RequestOption) (res *Agent, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -60,7 +60,7 @@ func (r *AgentService) Get(ctx context.Context, agentID string, opts ...option.R
return res, err
}
-// Agent
+// Update agent
func (r *AgentService) Update(ctx context.Context, agentID string, body AgentUpdateParams, opts ...option.RequestOption) (res *Agent, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -72,7 +72,7 @@ func (r *AgentService) Update(ctx context.Context, agentID string, body AgentUpd
return res, err
}
-// Agents
+// List agents
func (r *AgentService) List(ctx context.Context, query AgentListParams, opts ...option.RequestOption) (res *pagination.AgentsCursorPage[AgentSummary], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -90,12 +90,12 @@ func (r *AgentService) List(ctx context.Context, query AgentListParams, opts ...
return res, nil
}
-// Agents
+// List agents
func (r *AgentService) ListAutoPaging(ctx context.Context, query AgentListParams, opts ...option.RequestOption) *pagination.AgentsCursorPageAutoPager[AgentSummary] {
return pagination.NewAgentsCursorPageAutoPager(r.List(ctx, query, opts...))
}
-// Agent
+// Delete agent
func (r *AgentService) Delete(ctx context.Context, agentID string, opts ...option.RequestOption) (res *AgentDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -107,7 +107,7 @@ func (r *AgentService) Delete(ctx context.Context, agentID string, opts ...optio
return res, err
}
-// Tools
+// List tools
func (r *AgentService) ListTools(ctx context.Context, agentID string, opts ...option.RequestOption) (res *AgentListToolsResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -119,7 +119,7 @@ func (r *AgentService) ListTools(ctx context.Context, agentID string, opts ...op
return res, err
}
-// Config
+// Retrieve config
func (r *AgentService) GetConfig(ctx context.Context, agentID string, opts ...option.RequestOption) (res *EffectiveConfiguration, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -131,7 +131,7 @@ func (r *AgentService) GetConfig(ctx context.Context, agentID string, opts ...op
return res, err
}
-// Metadata
+// Update metadata
func (r *AgentService) UpdateMetadata(ctx context.Context, agentID string, body AgentUpdateMetadataParams, opts ...option.RequestOption) (res *Agent, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/approvalgrant.go b/approvalgrant.go
index 679c9fa..2685e71 100644
--- a/approvalgrant.go
+++ b/approvalgrant.go
@@ -37,7 +37,7 @@ func NewApprovalGrantService(opts ...option.RequestOption) (r *ApprovalGrantServ
return
}
-// Approval Grants
+// List approval grants
func (r *ApprovalGrantService) List(ctx context.Context, agentID string, query ApprovalGrantListParams, opts ...option.RequestOption) (res *pagination.GrantsCursorPage[ApprovalGrant], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -59,12 +59,12 @@ func (r *ApprovalGrantService) List(ctx context.Context, agentID string, query A
return res, nil
}
-// Approval Grants
+// List approval grants
func (r *ApprovalGrantService) ListAutoPaging(ctx context.Context, agentID string, query ApprovalGrantListParams, opts ...option.RequestOption) *pagination.GrantsCursorPageAutoPager[ApprovalGrant] {
return pagination.NewGrantsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
}
-// Approval Grant
+// Delete approval grant
func (r *ApprovalGrantService) Delete(ctx context.Context, agentID string, grantID string, opts ...option.RequestOption) (res *ApprovalGrantDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -80,7 +80,7 @@ func (r *ApprovalGrantService) Delete(ctx context.Context, agentID string, grant
return res, err
}
-// Approval Grant
+// Delete approval grant
func (r *ApprovalGrantService) DeleteForThread(ctx context.Context, agentID string, threadID string, grantID string, opts ...option.RequestOption) (res *ApprovalGrantDeleteForThreadResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -100,7 +100,7 @@ func (r *ApprovalGrantService) DeleteForThread(ctx context.Context, agentID stri
return res, err
}
-// Approval Grants
+// List approval grants
func (r *ApprovalGrantService) ListForThread(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (res *[]ApprovalGrant, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/approvalrequest.go b/approvalrequest.go
index 4706cc1..411cafc 100644
--- a/approvalrequest.go
+++ b/approvalrequest.go
@@ -38,7 +38,7 @@ func NewApprovalRequestService(opts ...option.RequestOption) (r *ApprovalRequest
return
}
-// Approvals
+// List approvals
func (r *ApprovalRequestService) List(ctx context.Context, agentID string, query ApprovalRequestListParams, opts ...option.RequestOption) (res *pagination.ApprovalRequestsCursorPage[ApprovalRequest], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -60,12 +60,12 @@ func (r *ApprovalRequestService) List(ctx context.Context, agentID string, query
return res, nil
}
-// Approvals
+// List approvals
func (r *ApprovalRequestService) ListAutoPaging(ctx context.Context, agentID string, query ApprovalRequestListParams, opts ...option.RequestOption) *pagination.ApprovalRequestsCursorPageAutoPager[ApprovalRequest] {
return pagination.NewApprovalRequestsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
}
-// Approval
+// Create approval
func (r *ApprovalRequestService) Resolve(ctx context.Context, agentID string, threadID string, approvalID string, body ApprovalRequestResolveParams, opts ...option.RequestOption) (res *ApprovalRequest, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/auth.go b/auth.go
index d2c081a..208db52 100644
--- a/auth.go
+++ b/auth.go
@@ -35,7 +35,7 @@ func NewAuthService(opts ...option.RequestOption) (r *AuthService) {
return
}
-// Context
+// Retrieve context
func (r *AuthService) Context(ctx context.Context, opts ...option.RequestOption) (res *AuthContextResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "auth/context"
@@ -43,7 +43,7 @@ func (r *AuthService) Context(ctx context.Context, opts ...option.RequestOption)
return res, err
}
-// Fleets
+// List fleets
func (r *AuthService) ListFleets(ctx context.Context, query AuthListFleetsParams, opts ...option.RequestOption) (res *pagination.FleetsCursorPage[Fleet], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -61,7 +61,7 @@ func (r *AuthService) ListFleets(ctx context.Context, query AuthListFleetsParams
return res, nil
}
-// Fleets
+// List fleets
func (r *AuthService) ListFleetsAutoPaging(ctx context.Context, query AuthListFleetsParams, opts ...option.RequestOption) *pagination.FleetsCursorPageAutoPager[Fleet] {
return pagination.NewFleetsCursorPageAutoPager(r.ListFleets(ctx, query, opts...))
}
diff --git a/connection.go b/connection.go
index 1d39d1f..6ea8d35 100644
--- a/connection.go
+++ b/connection.go
@@ -39,7 +39,7 @@ func NewConnectionService(opts ...option.RequestOption) (r *ConnectionService) {
return
}
-// API Keys
+// Create API key
func (r *ConnectionService) New(ctx context.Context, body ConnectionNewParams, opts ...option.RequestOption) (res *Connection, err error) {
opts = slices.Concat(r.Options, opts)
path := "connections/api-keys"
@@ -47,7 +47,7 @@ func (r *ConnectionService) New(ctx context.Context, body ConnectionNewParams, o
return res, err
}
-// Connections
+// List connections
func (r *ConnectionService) List(ctx context.Context, query ConnectionListParams, opts ...option.RequestOption) (res *pagination.ConnectionsCursorPage[Connection], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -65,12 +65,12 @@ func (r *ConnectionService) List(ctx context.Context, query ConnectionListParams
return res, nil
}
-// Connections
+// List connections
func (r *ConnectionService) ListAutoPaging(ctx context.Context, query ConnectionListParams, opts ...option.RequestOption) *pagination.ConnectionsCursorPageAutoPager[Connection] {
return pagination.NewConnectionsCursorPageAutoPager(r.List(ctx, query, opts...))
}
-// Connection
+// Delete connection
func (r *ConnectionService) Delete(ctx context.Context, connectionID string, body ConnectionDeleteParams, opts ...option.RequestOption) (res *ConnectionDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if connectionID == "" {
@@ -82,7 +82,7 @@ func (r *ConnectionService) Delete(ctx context.Context, connectionID string, bod
return res, err
}
-// Connections
+// Attach connection
func (r *ConnectionService) Attach(ctx context.Context, agentID string, body ConnectionAttachParams, opts ...option.RequestOption) (res *AttachedConnection, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -94,7 +94,7 @@ func (r *ConnectionService) Attach(ctx context.Context, agentID string, body Con
return res, err
}
-// Connection
+// Detach connection
func (r *ConnectionService) Detach(ctx context.Context, agentID string, connectionID string, opts ...option.RequestOption) (res *ConnectionDetachResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -110,7 +110,7 @@ func (r *ConnectionService) Detach(ctx context.Context, agentID string, connecti
return res, err
}
-// Connections
+// List connections
func (r *ConnectionService) ListForAgent(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ConnectionListForAgentResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/context.go b/context.go
index c8b2d6d..3cee37a 100644
--- a/context.go
+++ b/context.go
@@ -37,7 +37,7 @@ func NewContextService(opts ...option.RequestOption) (r *ContextService) {
return
}
-// Entry
+// Retrieve context entry
func (r *ContextService) Get(ctx context.Context, agentID string, query ContextGetParams, opts ...option.RequestOption) (res *Entry, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -49,7 +49,7 @@ func (r *ContextService) Get(ctx context.Context, agentID string, query ContextG
return res, err
}
-// Context
+// List context entries
func (r *ContextService) List(ctx context.Context, agentID string, query ContextListParams, opts ...option.RequestOption) (res *pagination.EntriesCursorPage[EntrySummary], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -71,12 +71,12 @@ func (r *ContextService) List(ctx context.Context, agentID string, query Context
return res, nil
}
-// Context
+// List context entries
func (r *ContextService) ListAutoPaging(ctx context.Context, agentID string, query ContextListParams, opts ...option.RequestOption) *pagination.EntriesCursorPageAutoPager[EntrySummary] {
return pagination.NewEntriesCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
}
-// Entry
+// Delete context entry
func (r *ContextService) Delete(ctx context.Context, agentID string, body ContextDeleteParams, opts ...option.RequestOption) (res *ContextDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -88,7 +88,7 @@ func (r *ContextService) Delete(ctx context.Context, agentID string, body Contex
return res, err
}
-// Search
+// Search context
func (r *ContextService) Search(ctx context.Context, agentID string, query ContextSearchParams, opts ...option.RequestOption) (res *pagination.ResultsCursorPage[SearchResult], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -110,12 +110,12 @@ func (r *ContextService) Search(ctx context.Context, agentID string, query Conte
return res, nil
}
-// Search
+// Search context
func (r *ContextService) SearchAutoPaging(ctx context.Context, agentID string, query ContextSearchParams, opts ...option.RequestOption) *pagination.ResultsCursorPageAutoPager[SearchResult] {
return pagination.NewResultsCursorPageAutoPager(r.Search(ctx, agentID, query, opts...))
}
-// Entry
+// Update context entry
func (r *ContextService) Write(ctx context.Context, agentID string, body ContextWriteParams, opts ...option.RequestOption) (res *Entry, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/event.go b/event.go
index 5ed26a0..391a692 100644
--- a/event.go
+++ b/event.go
@@ -40,7 +40,7 @@ func NewEventService(opts ...option.RequestOption) (r *EventService) {
return
}
-// Events
+// List events
func (r *EventService) ListForAgent(ctx context.Context, agentID string, query EventListForAgentParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -62,12 +62,12 @@ func (r *EventService) ListForAgent(ctx context.Context, agentID string, query E
return res, nil
}
-// Events
+// List events
func (r *EventService) ListForAgentAutoPaging(ctx context.Context, agentID string, query EventListForAgentParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
return pagination.NewEventsCursorPageAutoPager(r.ListForAgent(ctx, agentID, query, opts...))
}
-// Events
+// List events
func (r *EventService) ListForFleet(ctx context.Context, fleetID string, query EventListForFleetParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -89,12 +89,12 @@ func (r *EventService) ListForFleet(ctx context.Context, fleetID string, query E
return res, nil
}
-// Events
+// List events
func (r *EventService) ListForFleetAutoPaging(ctx context.Context, fleetID string, query EventListForFleetParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
return pagination.NewEventsCursorPageAutoPager(r.ListForFleet(ctx, fleetID, query, opts...))
}
-// Events
+// List events
func (r *EventService) ListForThread(ctx context.Context, agentID string, threadID string, query EventListForThreadParams, opts ...option.RequestOption) (res *pagination.EventsCursorPage[SubscriptionEvent], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -120,7 +120,7 @@ func (r *EventService) ListForThread(ctx context.Context, agentID string, thread
return res, nil
}
-// Events
+// List events
func (r *EventService) ListForThreadAutoPaging(ctx context.Context, agentID string, threadID string, query EventListForThreadParams, opts ...option.RequestOption) *pagination.EventsCursorPageAutoPager[SubscriptionEvent] {
return pagination.NewEventsCursorPageAutoPager(r.ListForThread(ctx, agentID, threadID, query, opts...))
}
diff --git a/model.go b/model.go
index d461c4a..6a5235d 100644
--- a/model.go
+++ b/model.go
@@ -31,7 +31,7 @@ func NewModelService(opts ...option.RequestOption) (r *ModelService) {
return
}
-// Models
+// List models
func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (res *ModelListResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "models"
diff --git a/oauth.go b/oauth.go
index 971bd38..439d07a 100644
--- a/oauth.go
+++ b/oauth.go
@@ -34,7 +34,7 @@ func NewOAuthService(opts ...option.RequestOption) (r *OAuthService) {
return
}
-// Connect
+// Start OAuth authorization
func (r *OAuthService) Connect(ctx context.Context, provider string, body OAuthConnectParams, opts ...option.RequestOption) (res *OAuthConnectResponse, err error) {
opts = slices.Concat(r.Options, opts)
if provider == "" {
diff --git a/sandbox.go b/sandbox.go
index 7792b16..77c647f 100644
--- a/sandbox.go
+++ b/sandbox.go
@@ -34,7 +34,7 @@ func NewSandboxService(opts ...option.RequestOption) (r *SandboxService) {
return
}
-// Exec
+// Execute sandbox command
func (r *SandboxService) Exec(ctx context.Context, agentID string, body SandboxExecParams, opts ...option.RequestOption) (res *ExecResult, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -46,7 +46,7 @@ func (r *SandboxService) Exec(ctx context.Context, agentID string, body SandboxE
return res, err
}
-// Read
+// Read sandbox file
func (r *SandboxService) Read(ctx context.Context, agentID string, body SandboxReadParams, opts ...option.RequestOption) (res *ReadResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -58,7 +58,7 @@ func (r *SandboxService) Read(ctx context.Context, agentID string, body SandboxR
return res, err
}
-// Write
+// Write sandbox file
func (r *SandboxService) Write(ctx context.Context, agentID string, body SandboxWriteParams, opts ...option.RequestOption) (res *SandboxWriteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/schedule.go b/schedule.go
index 404a4df..20aa089 100644
--- a/schedule.go
+++ b/schedule.go
@@ -36,7 +36,7 @@ func NewScheduleService(opts ...option.RequestOption) (r *ScheduleService) {
return
}
-// Schedules
+// Create schedule
func (r *ScheduleService) New(ctx context.Context, agentID string, body ScheduleNewParams, opts ...option.RequestOption) (res *Schedule, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -48,7 +48,7 @@ func (r *ScheduleService) New(ctx context.Context, agentID string, body Schedule
return res, err
}
-// Schedule
+// Update schedule
func (r *ScheduleService) Update(ctx context.Context, agentID string, scheduleID string, body ScheduleUpdateParams, opts ...option.RequestOption) (res *Schedule, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -64,7 +64,7 @@ func (r *ScheduleService) Update(ctx context.Context, agentID string, scheduleID
return res, err
}
-// Schedules
+// List schedules
func (r *ScheduleService) List(ctx context.Context, agentID string, opts ...option.RequestOption) (res *ScheduleListResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -76,7 +76,7 @@ func (r *ScheduleService) List(ctx context.Context, agentID string, opts ...opti
return res, err
}
-// Schedule
+// Delete schedule
func (r *ScheduleService) Delete(ctx context.Context, agentID string, scheduleID string, opts ...option.RequestOption) (res *ScheduleDeleteResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -92,7 +92,7 @@ func (r *ScheduleService) Delete(ctx context.Context, agentID string, scheduleID
return res, err
}
-// Trigger
+// Trigger schedule
func (r *ScheduleService) Trigger(ctx context.Context, agentID string, scheduleID string, opts ...option.RequestOption) (res *ScheduleTriggerResponse, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/thread.go b/thread.go
index eacf575..892e5a7 100644
--- a/thread.go
+++ b/thread.go
@@ -40,7 +40,7 @@ func NewThreadService(opts ...option.RequestOption) (r *ThreadService) {
return
}
-// Threads
+// Create thread
func (r *ThreadService) New(ctx context.Context, agentID string, body ThreadNewParams, opts ...option.RequestOption) (res *Thread, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -52,7 +52,7 @@ func (r *ThreadService) New(ctx context.Context, agentID string, body ThreadNewP
return res, err
}
-// Thread
+// Retrieve thread
func (r *ThreadService) Get(ctx context.Context, agentID string, threadID string, query ThreadGetParams, opts ...option.RequestOption) (res *Thread, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
@@ -68,7 +68,7 @@ func (r *ThreadService) Get(ctx context.Context, agentID string, threadID string
return res, err
}
-// Threads
+// List threads
func (r *ThreadService) List(ctx context.Context, agentID string, query ThreadListParams, opts ...option.RequestOption) (res *pagination.ThreadsCursorPage[ThreadSummary], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -90,7 +90,7 @@ func (r *ThreadService) List(ctx context.Context, agentID string, query ThreadLi
return res, nil
}
-// Threads
+// List threads
func (r *ThreadService) ListAutoPaging(ctx context.Context, agentID string, query ThreadListParams, opts ...option.RequestOption) *pagination.ThreadsCursorPageAutoPager[ThreadSummary] {
return pagination.NewThreadsCursorPageAutoPager(r.List(ctx, agentID, query, opts...))
}
@@ -146,7 +146,7 @@ func (r *ThreadService) Compact(ctx context.Context, agentID string, threadID st
return res, err
}
-// Turns
+// Create turn
func (r *ThreadService) StartTurn(ctx context.Context, agentID string, threadID string, body ThreadStartTurnParams, opts ...option.RequestOption) (res *Turn, err error) {
opts = slices.Concat(r.Options, opts)
if agentID == "" {
diff --git a/tool.go b/tool.go
index e9af549..bd37885 100644
--- a/tool.go
+++ b/tool.go
@@ -39,7 +39,7 @@ func NewToolService(opts ...option.RequestOption) (r *ToolService) {
return
}
-// Tool Sources
+// Create tool source
func (r *ToolService) New(ctx context.Context, fleetID string, body ToolNewParams, opts ...option.RequestOption) (res *ToolSource, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -51,7 +51,7 @@ func (r *ToolService) New(ctx context.Context, fleetID string, body ToolNewParam
return res, err
}
-// Tool Source
+// Retrieve tool source
func (r *ToolService) Get(ctx context.Context, fleetID string, sourceID string, opts ...option.RequestOption) (res *ToolSource, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -67,7 +67,7 @@ func (r *ToolService) Get(ctx context.Context, fleetID string, sourceID string,
return res, err
}
-// Tool Source
+// Update tool source
func (r *ToolService) Update(ctx context.Context, fleetID string, sourceID string, body ToolUpdateParams, opts ...option.RequestOption) (res *ToolSource, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -83,7 +83,7 @@ func (r *ToolService) Update(ctx context.Context, fleetID string, sourceID strin
return res, err
}
-// Tool Sources
+// List tool sources
func (r *ToolService) List(ctx context.Context, fleetID string, query ToolListParams, opts ...option.RequestOption) (res *pagination.SourcesCursorPage[ToolSource], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -105,12 +105,12 @@ func (r *ToolService) List(ctx context.Context, fleetID string, query ToolListPa
return res, nil
}
-// Tool Sources
+// List tool sources
func (r *ToolService) ListAutoPaging(ctx context.Context, fleetID string, query ToolListParams, opts ...option.RequestOption) *pagination.SourcesCursorPageAutoPager[ToolSource] {
return pagination.NewSourcesCursorPageAutoPager(r.List(ctx, fleetID, query, opts...))
}
-// Tool Source
+// Delete tool source
func (r *ToolService) Delete(ctx context.Context, fleetID string, sourceID string, opts ...option.RequestOption) (err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
diff --git a/webhook.go b/webhook.go
index d7a71d0..583b841 100644
--- a/webhook.go
+++ b/webhook.go
@@ -37,7 +37,7 @@ func NewWebhookService(opts ...option.RequestOption) (r *WebhookService) {
return
}
-// Webhooks
+// Create webhook
func (r *WebhookService) New(ctx context.Context, fleetID string, body WebhookNewParams, opts ...option.RequestOption) (res *WebhookSubscriptionCreated, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -49,7 +49,7 @@ func (r *WebhookService) New(ctx context.Context, fleetID string, body WebhookNe
return res, err
}
-// Webhook
+// Retrieve webhook
func (r *WebhookService) Get(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookSubscription, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -65,7 +65,7 @@ func (r *WebhookService) Get(ctx context.Context, fleetID string, webhookID stri
return res, err
}
-// Webhook
+// Update webhook
func (r *WebhookService) Update(ctx context.Context, fleetID string, webhookID string, body WebhookUpdateParams, opts ...option.RequestOption) (res *WebhookSubscription, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -81,7 +81,7 @@ func (r *WebhookService) Update(ctx context.Context, fleetID string, webhookID s
return res, err
}
-// Webhooks
+// List webhooks
func (r *WebhookService) List(ctx context.Context, fleetID string, query WebhookListParams, opts ...option.RequestOption) (res *pagination.SubscriptionsCursorPage[WebhookSubscription], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -103,12 +103,12 @@ func (r *WebhookService) List(ctx context.Context, fleetID string, query Webhook
return res, nil
}
-// Webhooks
+// List webhooks
func (r *WebhookService) ListAutoPaging(ctx context.Context, fleetID string, query WebhookListParams, opts ...option.RequestOption) *pagination.SubscriptionsCursorPageAutoPager[WebhookSubscription] {
return pagination.NewSubscriptionsCursorPageAutoPager(r.List(ctx, fleetID, query, opts...))
}
-// Webhook
+// Delete webhook
func (r *WebhookService) Delete(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
@@ -125,7 +125,7 @@ func (r *WebhookService) Delete(ctx context.Context, fleetID string, webhookID s
return err
}
-// Rotate
+// Rotate webhook secret
func (r *WebhookService) Rotate(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookSubscriptionCreated, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
@@ -141,7 +141,7 @@ func (r *WebhookService) Rotate(ctx context.Context, fleetID string, webhookID s
return res, err
}
-// Test
+// Send test webhook
func (r *WebhookService) Test(ctx context.Context, fleetID string, webhookID string, opts ...option.RequestOption) (res *WebhookTestResponse, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
From 3ca41148adb9dc03111d5148841027e017413d20 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 20:46:02 +0000
Subject: [PATCH 15/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index 450db1f..acc8d86 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-fdb0c332c7ecd66c4dbed402d9b5a188e6924adc9791402ebd7aabca591c5ce5.yml
openapi_spec_hash: 65f7de0df776dc1df073cca2154a3684
-config_hash: 760e5624c524327bcfb49e54b9e3a6e2
+config_hash: 0fcefab9f2ace589b09162edfb71075e
From 7186cf44e7afe725bce3037f6a2aa6b4d15131c9 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 20:48:47 +0000
Subject: [PATCH 16/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index acc8d86..e3a4ef1 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-fdb0c332c7ecd66c4dbed402d9b5a188e6924adc9791402ebd7aabca591c5ce5.yml
openapi_spec_hash: 65f7de0df776dc1df073cca2154a3684
-config_hash: 0fcefab9f2ace589b09162edfb71075e
+config_hash: d608cd537ac13c1b72e5695616b0cc03
From 338ac0463b531a276c09d639e5c248b9742c46b4 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 21:28:28 +0000
Subject: [PATCH 17/29] codegen metadata
---
.stats.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index e3a4ef1..4192217 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-fdb0c332c7ecd66c4dbed402d9b5a188e6924adc9791402ebd7aabca591c5ce5.yml
-openapi_spec_hash: 65f7de0df776dc1df073cca2154a3684
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-75f3fdca3a62a1f38bf016804bcad6babeaa009e2b8285bf1e134351b0ae00a3.yml
+openapi_spec_hash: 5c3c9aa396df85e9bfa897fb0a9a331f
config_hash: d608cd537ac13c1b72e5695616b0cc03
From df5c5b22a398b4657f8ac600c701018b636dc4c4 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 30 Apr 2026 22:02:19 +0000
Subject: [PATCH 18/29] codegen metadata
---
.stats.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index 4192217..e3a4ef1 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-75f3fdca3a62a1f38bf016804bcad6babeaa009e2b8285bf1e134351b0ae00a3.yml
-openapi_spec_hash: 5c3c9aa396df85e9bfa897fb0a9a331f
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-fdb0c332c7ecd66c4dbed402d9b5a188e6924adc9791402ebd7aabca591c5ce5.yml
+openapi_spec_hash: 65f7de0df776dc1df073cca2154a3684
config_hash: d608cd537ac13c1b72e5695616b0cc03
From b87d3caf820dceb55385e68abc20ed9a98f3f59a Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 00:28:15 +0000
Subject: [PATCH 19/29] feat(api): api update
---
.stats.yml | 6 +++---
api.md | 10 +++++-----
tool.go | 16 ++++++++--------
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index e3a4ef1..07cfd3f 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-fdb0c332c7ecd66c4dbed402d9b5a188e6924adc9791402ebd7aabca591c5ce5.yml
-openapi_spec_hash: 65f7de0df776dc1df073cca2154a3684
-config_hash: d608cd537ac13c1b72e5695616b0cc03
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-126a8130c9097b4a9f27967c53a61b065ee82dd5a8460a49340cca07110545eb.yml
+openapi_spec_hash: 4f24ca6ba2455cf2cdcfb03417561a2e
+config_hash: a358dc0011bba32d4d2cabb1e6388d09
diff --git a/api.md b/api.md
index 649f888..060e3ac 100644
--- a/api.md
+++ b/api.md
@@ -99,11 +99,11 @@ Response Types:
Methods:
-- client.Tools.New(ctx context.Context, fleetID string, body cercago.ToolNewParams) (\*cercago.ToolSource, error)
-- client.Tools.Get(ctx context.Context, fleetID string, sourceID string) (\*cercago.ToolSource, error)
-- client.Tools.Update(ctx context.Context, fleetID string, sourceID string, body cercago.ToolUpdateParams) (\*cercago.ToolSource, error)
-- client.Tools.List(ctx context.Context, fleetID string, query cercago.ToolListParams) (\*pagination.SourcesCursorPage[cercago.ToolSource], error)
-- client.Tools.Delete(ctx context.Context, fleetID string, sourceID string) error
+- client.Tools.New(ctx context.Context, fleetID string, body cercago.ToolNewParams) (\*cercago.ToolSource, error)
+- client.Tools.Get(ctx context.Context, fleetID string, sourceID string) (\*cercago.ToolSource, error)
+- client.Tools.Update(ctx context.Context, fleetID string, sourceID string, body cercago.ToolUpdateParams) (\*cercago.ToolSource, error)
+- client.Tools.List(ctx context.Context, fleetID string, query cercago.ToolListParams) (\*pagination.SourcesCursorPage[cercago.ToolSource], error)
+- client.Tools.Delete(ctx context.Context, fleetID string, sourceID string) error
# Webhooks
diff --git a/tool.go b/tool.go
index bd37885..7eea2de 100644
--- a/tool.go
+++ b/tool.go
@@ -39,14 +39,14 @@ func NewToolService(opts ...option.RequestOption) (r *ToolService) {
return
}
-// Create tool source
+// Create tool
func (r *ToolService) New(ctx context.Context, fleetID string, body ToolNewParams, opts ...option.RequestOption) (res *ToolSource, err error) {
opts = slices.Concat(r.Options, opts)
if fleetID == "" {
err = errors.New("missing required fleetId parameter")
return nil, err
}
- path := fmt.Sprintf("fleets/%s/tool-sources", fleetID)
+ path := fmt.Sprintf("fleets/%s/tools", fleetID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
@@ -62,7 +62,7 @@ func (r *ToolService) Get(ctx context.Context, fleetID string, sourceID string,
err = errors.New("missing required sourceId parameter")
return nil, err
}
- path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
+ path := fmt.Sprintf("fleets/%s/tools/%s", fleetID, sourceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
@@ -78,12 +78,12 @@ func (r *ToolService) Update(ctx context.Context, fleetID string, sourceID strin
err = errors.New("missing required sourceId parameter")
return nil, err
}
- path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
+ path := fmt.Sprintf("fleets/%s/tools/%s", fleetID, sourceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
return res, err
}
-// List tool sources
+// List tools
func (r *ToolService) List(ctx context.Context, fleetID string, query ToolListParams, opts ...option.RequestOption) (res *pagination.SourcesCursorPage[ToolSource], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
@@ -92,7 +92,7 @@ func (r *ToolService) List(ctx context.Context, fleetID string, query ToolListPa
err = errors.New("missing required fleetId parameter")
return nil, err
}
- path := fmt.Sprintf("fleets/%s/tool-sources", fleetID)
+ path := fmt.Sprintf("fleets/%s/tools", fleetID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
@@ -105,7 +105,7 @@ func (r *ToolService) List(ctx context.Context, fleetID string, query ToolListPa
return res, nil
}
-// List tool sources
+// List tools
func (r *ToolService) ListAutoPaging(ctx context.Context, fleetID string, query ToolListParams, opts ...option.RequestOption) *pagination.SourcesCursorPageAutoPager[ToolSource] {
return pagination.NewSourcesCursorPageAutoPager(r.List(ctx, fleetID, query, opts...))
}
@@ -122,7 +122,7 @@ func (r *ToolService) Delete(ctx context.Context, fleetID string, sourceID strin
err = errors.New("missing required sourceId parameter")
return err
}
- path := fmt.Sprintf("fleets/%s/tool-sources/%s", fleetID, sourceID)
+ path := fmt.Sprintf("fleets/%s/tools/%s", fleetID, sourceID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return err
}
From 04e8d5173838e047a3ebd163f39d4c9d64d020c2 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 00:31:06 +0000
Subject: [PATCH 20/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index 07cfd3f..cd19870 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-126a8130c9097b4a9f27967c53a61b065ee82dd5a8460a49340cca07110545eb.yml
openapi_spec_hash: 4f24ca6ba2455cf2cdcfb03417561a2e
-config_hash: a358dc0011bba32d4d2cabb1e6388d09
+config_hash: 12f554adb8f737d803086a4fee707523
From cdbaf37a279069847045eb634f2fdbdd7c675c97 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 00:37:40 +0000
Subject: [PATCH 21/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index cd19870..bc8c0a3 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-126a8130c9097b4a9f27967c53a61b065ee82dd5a8460a49340cca07110545eb.yml
openapi_spec_hash: 4f24ca6ba2455cf2cdcfb03417561a2e
-config_hash: 12f554adb8f737d803086a4fee707523
+config_hash: 95193dd2f3e0bf347065be80e30e4f35
From 6718c030c4f22713ce4e6483aa76f54ca98f7846 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 00:39:08 +0000
Subject: [PATCH 22/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index bc8c0a3..5e8a112 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-126a8130c9097b4a9f27967c53a61b065ee82dd5a8460a49340cca07110545eb.yml
openapi_spec_hash: 4f24ca6ba2455cf2cdcfb03417561a2e
-config_hash: 95193dd2f3e0bf347065be80e30e4f35
+config_hash: 34efc196407e28c8ee4aac13cc8520a5
From 4cc4d6f80cc680ede96125c9c38ce7028524fb0a Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 00:42:17 +0000
Subject: [PATCH 23/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index 5e8a112..f3332ef 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-126a8130c9097b4a9f27967c53a61b065ee82dd5a8460a49340cca07110545eb.yml
openapi_spec_hash: 4f24ca6ba2455cf2cdcfb03417561a2e
-config_hash: 34efc196407e28c8ee4aac13cc8520a5
+config_hash: da443026eefb0a14005efb0fb4fd1624
From 3ff26aec2076f4fe685a43d37d2ee3b2704aa655 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 02:18:23 +0000
Subject: [PATCH 24/29] codegen metadata
---
.stats.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.stats.yml b/.stats.yml
index f3332ef..0645102 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-126a8130c9097b4a9f27967c53a61b065ee82dd5a8460a49340cca07110545eb.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-5043c4f9e500dc434652661de924412e231cff55010599d6d7035091b25ba8b9.yml
openapi_spec_hash: 4f24ca6ba2455cf2cdcfb03417561a2e
config_hash: da443026eefb0a14005efb0fb4fd1624
From 3a4ca71ce279af304fce557e47a883a0a80dd285 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 02:21:06 +0000
Subject: [PATCH 25/29] chore: avoid embedding reflect.Type for dead code
elimination
---
internal/apiform/encoder.go | 4 ++--
internal/apijson/decoder.go | 4 ++--
internal/apijson/encoder.go | 4 ++--
internal/apiquery/encoder.go | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/internal/apiform/encoder.go b/internal/apiform/encoder.go
index 7edf421..5040aba 100644
--- a/internal/apiform/encoder.go
+++ b/internal/apiform/encoder.go
@@ -42,7 +42,7 @@ type encoderField struct {
}
type encoderEntry struct {
- reflect.Type
+ typ reflect.Type
dateFormat string
root bool
}
@@ -59,7 +59,7 @@ func (e *encoder) marshal(value interface{}, writer *multipart.Writer) error {
func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
- Type: t,
+ typ: t,
dateFormat: e.dateFormat,
root: e.root,
}
diff --git a/internal/apijson/decoder.go b/internal/apijson/decoder.go
index bf01bf6..f5fe7e3 100644
--- a/internal/apijson/decoder.go
+++ b/internal/apijson/decoder.go
@@ -75,7 +75,7 @@ type decoderField struct {
}
type decoderEntry struct {
- reflect.Type
+ typ reflect.Type
dateFormat string
root bool
}
@@ -91,7 +91,7 @@ func (d *decoderBuilder) unmarshal(raw []byte, to any) error {
func (d *decoderBuilder) typeDecoder(t reflect.Type) decoderFunc {
entry := decoderEntry{
- Type: t,
+ typ: t,
dateFormat: d.dateFormat,
root: d.root,
}
diff --git a/internal/apijson/encoder.go b/internal/apijson/encoder.go
index ae34464..86d645c 100644
--- a/internal/apijson/encoder.go
+++ b/internal/apijson/encoder.go
@@ -46,7 +46,7 @@ type encoderField struct {
}
type encoderEntry struct {
- reflect.Type
+ typ reflect.Type
dateFormat string
root bool
}
@@ -63,7 +63,7 @@ func (e *encoder) marshal(value interface{}) ([]byte, error) {
func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
- Type: t,
+ typ: t,
dateFormat: e.dateFormat,
root: e.root,
}
diff --git a/internal/apiquery/encoder.go b/internal/apiquery/encoder.go
index 6f832d8..499cc10 100644
--- a/internal/apiquery/encoder.go
+++ b/internal/apiquery/encoder.go
@@ -29,7 +29,7 @@ type encoderField struct {
}
type encoderEntry struct {
- reflect.Type
+ typ reflect.Type
dateFormat string
root bool
settings QuerySettings
@@ -42,7 +42,7 @@ type Pair struct {
func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
- Type: t,
+ typ: t,
dateFormat: e.dateFormat,
root: e.root,
settings: e.settings,
From 32b19de5d484f43a038b564033888a04f29d382a Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 05:13:25 +0000
Subject: [PATCH 26/29] codegen metadata
---
.stats.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index 0645102..0b5de47 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-5043c4f9e500dc434652661de924412e231cff55010599d6d7035091b25ba8b9.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-6281c04b5f694232a2da7ab966248fc3f95b40f8bcc905950f8f869c1cfed7c4.yml
openapi_spec_hash: 4f24ca6ba2455cf2cdcfb03417561a2e
-config_hash: da443026eefb0a14005efb0fb4fd1624
+config_hash: c52c4e118e786c30eb5feba4bdb4eef4
From b9529a78864b854b60371646f70d1734381c66a3 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 19:21:05 +0000
Subject: [PATCH 27/29] codegen metadata
---
.stats.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index 0b5de47..e88d646 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 63
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-6281c04b5f694232a2da7ab966248fc3f95b40f8bcc905950f8f869c1cfed7c4.yml
-openapi_spec_hash: 4f24ca6ba2455cf2cdcfb03417561a2e
-config_hash: c52c4e118e786c30eb5feba4bdb4eef4
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-915843e0f51dd9526706e2dbf3ec040098453e85a5e17e1aa95b1fad0f005974.yml
+openapi_spec_hash: 1bf2de52141389b5474ca9db2f9d0f4e
+config_hash: 65d266b3a22059ee62fd0e8487aa5c17
From 59da953ed2c87a54dfa22a339651d6b1cf48ddce Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 23:57:56 +0000
Subject: [PATCH 28/29] feat(api): api update
---
.stats.yml | 8 +-
agent.go | 18 +-
aliases.go | 6 -
api.md | 18 +-
client_test.go | 108 +++
event.go | 1585 +++++++++++++++++++++++++++++--
event_test.go | 70 --
packages/ssestream/ssestream.go | 192 ++++
shared/shared.go | 29 -
tool.go | 602 ++++++------
tool_test.go | 16 +-
11 files changed, 2120 insertions(+), 532 deletions(-)
create mode 100644 packages/ssestream/ssestream.go
diff --git a/.stats.yml b/.stats.yml
index e88d646..57e5ba5 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 63
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-915843e0f51dd9526706e2dbf3ec040098453e85a5e17e1aa95b1fad0f005974.yml
-openapi_spec_hash: 1bf2de52141389b5474ca9db2f9d0f4e
-config_hash: 65d266b3a22059ee62fd0e8487aa5c17
+configured_endpoints: 64
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/calvinfo-o4h6u5/cerca-a3610b6045d1d701859276e09dff35829bdf50509b762116860d8005831b0297.yml
+openapi_spec_hash: 2a240632b5ef4814881e36247ec3c8dc
+config_hash: 5d687451efd1d2898e81fa3ddb25f8ed
diff --git a/agent.go b/agent.go
index 12e8fbc..7200dbe 100644
--- a/agent.go
+++ b/agent.go
@@ -654,8 +654,7 @@ func (r sourceWarningJSON) RawJSON() string {
type Tool struct {
Category ToolCategory `json:"category" api:"required"`
Description string `json:"description" api:"required"`
- // This field can have the runtime type of [shared.JsonObject],
- // [map[string]interface{}].
+ // This field can have the runtime type of [map[string]interface{}].
InputSchema interface{} `json:"inputSchema" api:"required"`
Name shared.ToolName `json:"name" api:"required"`
AccountLabel string `json:"accountLabel"`
@@ -807,13 +806,14 @@ func (r ToolOrigin) IsKnown() bool {
// A built-in or configurable runtime tool currently available to the agent.
type ToolDescriptor struct {
- ApprovalSource ToolDescriptorApprovalSource `json:"approvalSource" api:"required"`
- Category ToolDescriptorCategory `json:"category" api:"required"`
- Description string `json:"description" api:"required"`
- InputSchema shared.JsonObject `json:"inputSchema" api:"required"`
- Name shared.ToolName `json:"name" api:"required"`
- RequiresApproval bool `json:"requiresApproval" api:"required"`
- JSON toolDescriptorJSON `json:"-"`
+ ApprovalSource ToolDescriptorApprovalSource `json:"approvalSource" api:"required"`
+ Category ToolDescriptorCategory `json:"category" api:"required"`
+ Description string `json:"description" api:"required"`
+ // JSON Schema object describing tool input parameters.
+ InputSchema map[string]interface{} `json:"inputSchema" api:"required"`
+ Name shared.ToolName `json:"name" api:"required"`
+ RequiresApproval bool `json:"requiresApproval" api:"required"`
+ JSON toolDescriptorJSON `json:"-"`
}
// toolDescriptorJSON contains the JSON metadata for the struct [ToolDescriptor]
diff --git a/aliases.go b/aliases.go
index c0d9592..0b3eac1 100644
--- a/aliases.go
+++ b/aliases.go
@@ -18,12 +18,6 @@ const ApprovalModeAlways = shared.ApprovalModeAlways
// This is an alias to an internal value.
const ApprovalModeNever = shared.ApprovalModeNever
-// This is an alias to an internal type.
-type ErrorResponse = shared.ErrorResponse
-
-// This is an alias to an internal type.
-type JsonObject = shared.JsonObject
-
// This is an alias to an internal type.
type ToolName = shared.ToolName
diff --git a/api.md b/api.md
index 060e3ac..d429f6d 100644
--- a/api.md
+++ b/api.md
@@ -7,8 +7,6 @@
# Shared Response Types
- shared.ApprovalMode
-- shared.ErrorResponse
-- shared.JsonObject
- shared.ToolName
- shared.ToolSpec
@@ -72,18 +70,23 @@ Response Types:
Params Types:
+- cercago.APIKeyToolSourceAuthParam
- cercago.AuthInjectionUnionParam
- cercago.HTTPEndpointParam
- cercago.HTTPToolDefinitionParam
- cercago.HTTPToolExecutionPolicyParam
- cercago.McpToolExecutionPolicyParam
+- cercago.NoToolSourceAuthParam
+- cercago.OAuthConnectionToolSourceAuthParam
- cercago.OAuthExchangeConfigUnionParam
+- cercago.OAuthExchangeToolSourceAuthParam
- cercago.ResponseNormalizationHintParam
- cercago.ToolApprovalMode
- cercago.ToolSourceAuthUnionParam
Response Types:
+- cercago.APIKeyToolSourceAuth
- cercago.AuthInjection
- cercago.HTTPEndpoint
- cercago.HTTPToolDefinition
@@ -91,7 +94,10 @@ Response Types:
- cercago.HTTPToolSource
- cercago.McpToolExecutionPolicy
- cercago.McpToolSource
+- cercago.NoToolSourceAuth
+- cercago.OAuthConnectionToolSourceAuth
- cercago.OAuthExchangeConfig
+- cercago.OAuthExchangeToolSourceAuth
- cercago.ResponseNormalizationHint
- cercago.ToolApprovalMode
- cercago.ToolSource
@@ -134,15 +140,17 @@ Response Types:
- cercago.RuntimeWebhookEvent
- cercago.SubscriptionEvent
+- cercago.ThreadStreamEvent
Methods:
- client.Events.ListForAgent(ctx context.Context, agentID string, query cercago.EventListForAgentParams) (\*pagination.EventsCursorPage[cercago.SubscriptionEvent], error)
- client.Events.ListForFleet(ctx context.Context, fleetID string, query cercago.EventListForFleetParams) (\*pagination.EventsCursorPage[cercago.SubscriptionEvent], error)
- client.Events.ListForThread(ctx context.Context, agentID string, threadID string, query cercago.EventListForThreadParams) (\*pagination.EventsCursorPage[cercago.SubscriptionEvent], error)
-- client.Events.SubscribeAgent(ctx context.Context, agentID string) (\*shared.ErrorResponse, error)
-- client.Events.SubscribeFleet(ctx context.Context, fleetID string) (\*shared.ErrorResponse, error)
-- client.Events.SubscribeThread(ctx context.Context, agentID string, threadID string) (\*shared.ErrorResponse, error)
+- client.Events.StreamForAgent(ctx context.Context, agentID string, params cercago.EventStreamForAgentParams) (\*cercago.SubscriptionEvent, error)
+- client.Events.StreamForFleet(ctx context.Context, fleetID string, params cercago.EventStreamForFleetParams) (\*cercago.SubscriptionEvent, error)
+- client.Events.StreamForThread(ctx context.Context, agentID string, threadID string) (\*cercago.ThreadStreamEvent, error)
+- client.Events.StreamForThreadEvents(ctx context.Context, agentID string, threadID string, params cercago.EventStreamForThreadEventsParams) (\*cercago.SubscriptionEvent, error)
# Agents
diff --git a/client_test.go b/client_test.go
index 63587e8..9439725 100644
--- a/client_test.go
+++ b/client_test.go
@@ -5,6 +5,7 @@ package cercago_test
import (
"context"
"fmt"
+ "io"
"net/http"
"reflect"
"testing"
@@ -257,3 +258,110 @@ func TestContextDeadline(t *testing.T) {
}
}
}
+
+func TestContextDeadlineStreaming(t *testing.T) {
+ testTimeout := time.After(3 * time.Second)
+ testDone := make(chan struct{})
+
+ deadline := time.Now().Add(100 * time.Millisecond)
+ deadlineCtx, cancel := context.WithDeadline(context.Background(), deadline)
+ defer cancel()
+
+ go func() {
+ client := cercago.NewClient(
+ option.WithAPIKey("My API Key"),
+ option.WithHTTPClient(&http.Client{
+ Transport: &closureTransport{
+ fn: func(req *http.Request) (*http.Response, error) {
+ return &http.Response{
+ StatusCode: 200,
+ Status: "200 OK",
+ Body: io.NopCloser(
+ io.Reader(readerFunc(func([]byte) (int, error) {
+ <-req.Context().Done()
+ return 0, req.Context().Err()
+ })),
+ ),
+ }, nil
+ },
+ },
+ }),
+ )
+ stream := client.Events.StreamForAgentStreaming(
+ deadlineCtx,
+ "agent_abc123",
+ cercago.EventStreamForAgentParams{},
+ )
+ for stream.Next() {
+ _ = stream.Current()
+ }
+ if stream.Err() == nil {
+ t.Error("expected there to be a deadline error")
+ }
+ close(testDone)
+ }()
+
+ select {
+ case <-testTimeout:
+ t.Fatal("client didn't finish in time")
+ case <-testDone:
+ if diff := time.Since(deadline); diff < -30*time.Millisecond || 30*time.Millisecond < diff {
+ t.Fatalf("client did not return within 30ms of context deadline, got %s", diff)
+ }
+ }
+}
+
+func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) {
+ testTimeout := time.After(3 * time.Second)
+ testDone := make(chan struct{})
+ deadline := time.Now().Add(100 * time.Millisecond)
+
+ go func() {
+ client := cercago.NewClient(
+ option.WithAPIKey("My API Key"),
+ option.WithHTTPClient(&http.Client{
+ Transport: &closureTransport{
+ fn: func(req *http.Request) (*http.Response, error) {
+ return &http.Response{
+ StatusCode: 200,
+ Status: "200 OK",
+ Body: io.NopCloser(
+ io.Reader(readerFunc(func([]byte) (int, error) {
+ <-req.Context().Done()
+ return 0, req.Context().Err()
+ })),
+ ),
+ }, nil
+ },
+ },
+ }),
+ )
+ stream := client.Events.StreamForAgentStreaming(
+ context.Background(),
+ "agent_abc123",
+ cercago.EventStreamForAgentParams{},
+ option.WithRequestTimeout((100 * time.Millisecond)),
+ )
+ for stream.Next() {
+ _ = stream.Current()
+ }
+ if stream.Err() == nil {
+ t.Error("expected there to be a deadline error")
+ }
+ close(testDone)
+ }()
+
+ select {
+ case <-testTimeout:
+ t.Fatal("client didn't finish in time")
+ case <-testDone:
+ if diff := time.Since(deadline); diff < -30*time.Millisecond || 30*time.Millisecond < diff {
+ t.Fatalf("client did not return within 30ms of context deadline, got %s", diff)
+ }
+ }
+}
+
+type readerFunc func([]byte) (int, error)
+
+func (f readerFunc) Read(p []byte) (int, error) { return f(p) }
+func (f readerFunc) Close() error { return nil }
diff --git a/event.go b/event.go
index 391a692..ee75445 100644
--- a/event.go
+++ b/event.go
@@ -17,6 +17,7 @@ import (
"github.com/matrices/cerca-go/internal/requestconfig"
"github.com/matrices/cerca-go/option"
"github.com/matrices/cerca-go/packages/pagination"
+ "github.com/matrices/cerca-go/packages/ssestream"
"github.com/matrices/cerca-go/shared"
"github.com/tidwall/gjson"
)
@@ -125,54 +126,93 @@ func (r *EventService) ListForThreadAutoPaging(ctx context.Context, agentID stri
return pagination.NewEventsCursorPageAutoPager(r.ListForThread(ctx, agentID, threadID, query, opts...))
}
-// WebSocket upgrade endpoint. Set
-// `Sec-WebSocket-Protocol: agent-v1, agent-auth-` so the runtime can
-// authenticate the stream while preserving the public subprotocol. HTTP clients
-// that cannot upgrade should use `/agents/{agentId}/events` as the polling analog.
-func (r *EventService) SubscribeAgent(ctx context.Context, agentID string, opts ...option.RequestOption) (res *shared.ErrorResponse, err error) {
+// Server-Sent Events stream. Each SSE data frame is JSON matching this response
+// schema.
+func (r *EventService) StreamForAgentStreaming(ctx context.Context, agentID string, params EventStreamForAgentParams, opts ...option.RequestOption) (stream *ssestream.Stream[SubscriptionEvent]) {
+ var (
+ raw *http.Response
+ err error
+ )
+ if params.LastEventID.Present {
+ opts = append(opts, option.WithHeader("Last-Event-ID", fmt.Sprintf("%v", params.LastEventID)))
+ }
opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithHeader("Accept", "text/event-stream")}, opts...)
if agentID == "" {
err = errors.New("missing required agentId parameter")
- return nil, err
+ return ssestream.NewStream[SubscriptionEvent](nil, err)
}
- path := fmt.Sprintf("agents/%s/events/subscribe", agentID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
+ path := fmt.Sprintf("agents/%s/events/stream", agentID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &raw, opts...)
+ return ssestream.NewStream[SubscriptionEvent](ssestream.NewDecoder(raw), err)
}
-// WebSocket upgrade endpoint. Set
-// `Sec-WebSocket-Protocol: agent-v1, agent-auth-` so the runtime can
-// authenticate the stream while preserving the public subprotocol. HTTP clients
-// that cannot upgrade should use `/fleets/{fleetId}/events` as the polling analog.
-func (r *EventService) SubscribeFleet(ctx context.Context, fleetID string, opts ...option.RequestOption) (res *shared.ErrorResponse, err error) {
+// Server-Sent Events stream. Each SSE data frame is JSON matching this response
+// schema.
+func (r *EventService) StreamForFleetStreaming(ctx context.Context, fleetID string, params EventStreamForFleetParams, opts ...option.RequestOption) (stream *ssestream.Stream[SubscriptionEvent]) {
+ var (
+ raw *http.Response
+ err error
+ )
+ if params.LastEventID.Present {
+ opts = append(opts, option.WithHeader("Last-Event-ID", fmt.Sprintf("%v", params.LastEventID)))
+ }
opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithHeader("Accept", "text/event-stream")}, opts...)
if fleetID == "" {
err = errors.New("missing required fleetId parameter")
- return nil, err
+ return ssestream.NewStream[SubscriptionEvent](nil, err)
}
- path := fmt.Sprintf("fleets/%s/events/subscribe", fleetID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
+ path := fmt.Sprintf("fleets/%s/events/stream", fleetID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &raw, opts...)
+ return ssestream.NewStream[SubscriptionEvent](ssestream.NewDecoder(raw), err)
}
-// WebSocket upgrade endpoint. Set
-// `Sec-WebSocket-Protocol: agent-v1, agent-auth-` so the runtime can
-// authenticate the stream while preserving the public subprotocol. HTTP clients
-// that cannot upgrade should use `/agents/{agentId}/threads/{threadId}/events` as
-// the polling analog.
-func (r *EventService) SubscribeThread(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (res *shared.ErrorResponse, err error) {
+// Server-Sent Events stream. Each SSE data frame is JSON matching this response
+// schema.
+func (r *EventService) StreamForThreadStreaming(ctx context.Context, agentID string, threadID string, opts ...option.RequestOption) (stream *ssestream.Stream[ThreadStreamEvent]) {
+ var (
+ raw *http.Response
+ err error
+ )
opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithHeader("Accept", "text/event-stream")}, opts...)
if agentID == "" {
err = errors.New("missing required agentId parameter")
- return nil, err
+ return ssestream.NewStream[ThreadStreamEvent](nil, err)
}
if threadID == "" {
err = errors.New("missing required threadId parameter")
- return nil, err
+ return ssestream.NewStream[ThreadStreamEvent](nil, err)
+ }
+ path := fmt.Sprintf("agents/%s/threads/%s/stream", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &raw, opts...)
+ return ssestream.NewStream[ThreadStreamEvent](ssestream.NewDecoder(raw), err)
+}
+
+// Server-Sent Events stream. Each SSE data frame is JSON matching this response
+// schema.
+func (r *EventService) StreamForThreadEventsStreaming(ctx context.Context, agentID string, threadID string, params EventStreamForThreadEventsParams, opts ...option.RequestOption) (stream *ssestream.Stream[SubscriptionEvent]) {
+ var (
+ raw *http.Response
+ err error
+ )
+ if params.LastEventID.Present {
+ opts = append(opts, option.WithHeader("Last-Event-ID", fmt.Sprintf("%v", params.LastEventID)))
+ }
+ opts = slices.Concat(r.Options, opts)
+ opts = append([]option.RequestOption{option.WithHeader("Accept", "text/event-stream")}, opts...)
+ if agentID == "" {
+ err = errors.New("missing required agentId parameter")
+ return ssestream.NewStream[SubscriptionEvent](nil, err)
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ return ssestream.NewStream[SubscriptionEvent](nil, err)
}
- path := fmt.Sprintf("agents/%s/threads/%s/events/subscribe", agentID, threadID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
- return res, err
+ path := fmt.Sprintf("agents/%s/threads/%s/events/stream", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &raw, opts...)
+ return ssestream.NewStream[SubscriptionEvent](ssestream.NewDecoder(raw), err)
}
type RuntimeWebhookEvent struct {
@@ -2219,112 +2259,1461 @@ func (r subscriptionEventJSON) RawJSON() string {
return r.raw
}
-type EventListForAgentParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Comma-separated event type filter.
- Events param.Field[string] `query:"events"`
- // When true, starts from the beginning of the retained buffer.
- History param.Field[EventListForAgentParamsHistory] `query:"history"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
+type ThreadStreamEvent struct {
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventType `json:"type" api:"required"`
+ // This field can have the runtime type of
+ // [ThreadStreamEventThreadStreamApprovalRequestedMessageApproval].
+ Approval interface{} `json:"approval"`
+ ApprovalID string `json:"approvalId"`
+ CumulativeInputTokens float64 `json:"cumulativeInputTokens"`
+ CumulativeOutputTokens float64 `json:"cumulativeOutputTokens"`
+ Decision ThreadStreamEventDecision `json:"decision"`
+ DurationMs float64 `json:"durationMs"`
+ Error string `json:"error" api:"nullable"`
+ InputTokens float64 `json:"inputTokens"`
+ IsError bool `json:"isError"`
+ ItemID string `json:"itemId"`
+ ItemType ThreadStreamEventItemType `json:"itemType"`
+ // This field can have the runtime type of
+ // [ThreadStreamEventThreadStreamContentMessageMessage].
+ Message interface{} `json:"message"`
+ MessageCount float64 `json:"messageCount"`
+ OutputTokens float64 `json:"outputTokens"`
+ RequestedToolName string `json:"requestedToolName"`
+ Result string `json:"result" api:"nullable"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ Status Status `json:"status"`
+ StepCount float64 `json:"stepCount"`
+ StepSeq float64 `json:"stepSeq"`
+ SubThreadID string `json:"subThreadId"`
+ ToolName shared.ToolName `json:"toolName"`
+ TurnSeq float64 `json:"turnSeq"`
+ JSON threadStreamEventJSON `json:"-"`
+ union ThreadStreamEventUnion
+}
+
+// threadStreamEventJSON contains the JSON metadata for the struct
+// [ThreadStreamEvent]
+type threadStreamEventJSON struct {
+ EventSeq apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ Approval apijson.Field
+ ApprovalID apijson.Field
+ CumulativeInputTokens apijson.Field
+ CumulativeOutputTokens apijson.Field
+ Decision apijson.Field
+ DurationMs apijson.Field
+ Error apijson.Field
+ InputTokens apijson.Field
+ IsError apijson.Field
+ ItemID apijson.Field
+ ItemType apijson.Field
+ Message apijson.Field
+ MessageCount apijson.Field
+ OutputTokens apijson.Field
+ RequestedToolName apijson.Field
+ Result apijson.Field
+ Status apijson.Field
+ StepCount apijson.Field
+ StepSeq apijson.Field
+ SubThreadID apijson.Field
+ ToolName apijson.Field
+ TurnSeq apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r threadStreamEventJSON) RawJSON() string {
+ return r.raw
}
-// URLQuery serializes [EventListForAgentParams]'s query parameters as
-// `url.Values`.
-func (r EventListForAgentParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
+func (r *ThreadStreamEvent) UnmarshalJSON(data []byte) (err error) {
+ *r = ThreadStreamEvent{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
}
-// When true, starts from the beginning of the retained buffer.
-type EventListForAgentParamsHistory string
+// AsUnion returns a [ThreadStreamEventUnion] interface which you can cast to the
+// specific types for more type safety.
+//
+// Possible runtime types of the union are
+// [ThreadStreamEventThreadStreamStatusMessage],
+// [ThreadStreamEventThreadStreamContentMessage],
+// [ThreadStreamEventThreadStreamProgressMessage],
+// [ThreadStreamEventThreadStreamTurnStartedMessage],
+// [ThreadStreamEventThreadStreamTurnCompletedMessage],
+// [ThreadStreamEventThreadStreamItemStartedMessage],
+// [ThreadStreamEventThreadStreamItemCompletedMessage],
+// [ThreadStreamEventThreadStreamTokenUsageMessage],
+// [ThreadStreamEventThreadStreamApprovalRequestedMessage],
+// [ThreadStreamEventThreadStreamApprovalResolvedMessage].
+func (r ThreadStreamEvent) AsUnion() ThreadStreamEventUnion {
+ return r.union
+}
+
+// Union satisfied by [ThreadStreamEventThreadStreamStatusMessage],
+// [ThreadStreamEventThreadStreamContentMessage],
+// [ThreadStreamEventThreadStreamProgressMessage],
+// [ThreadStreamEventThreadStreamTurnStartedMessage],
+// [ThreadStreamEventThreadStreamTurnCompletedMessage],
+// [ThreadStreamEventThreadStreamItemStartedMessage],
+// [ThreadStreamEventThreadStreamItemCompletedMessage],
+// [ThreadStreamEventThreadStreamTokenUsageMessage],
+// [ThreadStreamEventThreadStreamApprovalRequestedMessage] or
+// [ThreadStreamEventThreadStreamApprovalResolvedMessage].
+type ThreadStreamEventUnion interface {
+ implementsThreadStreamEvent()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ThreadStreamEventUnion)(nil)).Elem(),
+ "type",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamStatusMessage{}),
+ DiscriminatorValue: "status",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamContentMessage{}),
+ DiscriminatorValue: "message",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamProgressMessage{}),
+ DiscriminatorValue: "progress",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamTurnStartedMessage{}),
+ DiscriminatorValue: "turn/started",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamTurnCompletedMessage{}),
+ DiscriminatorValue: "turn/completed",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamItemStartedMessage{}),
+ DiscriminatorValue: "item/started",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamItemCompletedMessage{}),
+ DiscriminatorValue: "item/completed",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamTokenUsageMessage{}),
+ DiscriminatorValue: "token_usage",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamApprovalRequestedMessage{}),
+ DiscriminatorValue: "approval/requested",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamApprovalResolvedMessage{}),
+ DiscriminatorValue: "approval/resolved",
+ },
+ )
+}
+
+type ThreadStreamEventThreadStreamStatusMessage struct {
+ Error string `json:"error" api:"required,nullable"`
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ Result string `json:"result" api:"required,nullable"`
+ // `idle` threads can accept a new turn or be closed. `running` threads have an
+ // active turn. `awaiting` threads are paused on external input such as approvals.
+ // `closed` threads are terminal.
+ Status Status `json:"status" api:"required"`
+ StepSeq float64 `json:"stepSeq" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventThreadStreamStatusMessageType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamStatusMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamStatusMessageJSON contains the JSON metadata for
+// the struct [ThreadStreamEventThreadStreamStatusMessage]
+type threadStreamEventThreadStreamStatusMessageJSON struct {
+ Error apijson.Field
+ EventSeq apijson.Field
+ Result apijson.Field
+ Status apijson.Field
+ StepSeq apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamStatusMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamStatusMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamStatusMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamStatusMessageType string
const (
- EventListForAgentParamsHistoryTrue EventListForAgentParamsHistory = "true"
- EventListForAgentParamsHistoryFalse EventListForAgentParamsHistory = "false"
+ ThreadStreamEventThreadStreamStatusMessageTypeStatus ThreadStreamEventThreadStreamStatusMessageType = "status"
)
-func (r EventListForAgentParamsHistory) IsKnown() bool {
+func (r ThreadStreamEventThreadStreamStatusMessageType) IsKnown() bool {
switch r {
- case EventListForAgentParamsHistoryTrue, EventListForAgentParamsHistoryFalse:
+ case ThreadStreamEventThreadStreamStatusMessageTypeStatus:
return true
}
return false
}
-type EventListForFleetParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Comma-separated event type filter.
- Events param.Field[string] `query:"events"`
- // When true, starts from the beginning of the retained buffer.
- History param.Field[EventListForFleetParamsHistory] `query:"history"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
+type ThreadStreamEventThreadStreamContentMessage struct {
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ Message ThreadStreamEventThreadStreamContentMessageMessage `json:"message" api:"required"`
+ StepSeq float64 `json:"stepSeq" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventThreadStreamContentMessageType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamContentMessageJSON `json:"-"`
}
-// URLQuery serializes [EventListForFleetParams]'s query parameters as
-// `url.Values`.
-func (r EventListForFleetParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
+// threadStreamEventThreadStreamContentMessageJSON contains the JSON metadata for
+// the struct [ThreadStreamEventThreadStreamContentMessage]
+type threadStreamEventThreadStreamContentMessageJSON struct {
+ EventSeq apijson.Field
+ Message apijson.Field
+ StepSeq apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
}
-// When true, starts from the beginning of the retained buffer.
-type EventListForFleetParamsHistory string
+func (r *ThreadStreamEventThreadStreamContentMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamContentMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamContentMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamContentMessageMessage struct {
+ Content []ThreadStreamEventThreadStreamContentMessageMessageContent `json:"content" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ Role ThreadStreamEventThreadStreamContentMessageMessageRole `json:"role" api:"required"`
+ Seq float64 `json:"seq" api:"required"`
+ JSON threadStreamEventThreadStreamContentMessageMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamContentMessageMessageJSON contains the JSON
+// metadata for the struct [ThreadStreamEventThreadStreamContentMessageMessage]
+type threadStreamEventThreadStreamContentMessageMessageJSON struct {
+ Content apijson.Field
+ CreatedAt apijson.Field
+ Role apijson.Field
+ Seq apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamContentMessageMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamContentMessageMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContent struct {
+ Type ThreadStreamEventThreadStreamContentMessageMessageContentType `json:"type" api:"required"`
+ ID string `json:"id"`
+ // This field can have the runtime type of [string], [interface{}].
+ Content interface{} `json:"content"`
+ DeniedByUser bool `json:"deniedByUser"`
+ // JSON-serialized tool input payload. Parse as JSON before reading tool-specific
+ // fields.
+ Input string `json:"input"`
+ IsError bool `json:"isError"`
+ Name shared.ToolName `json:"name"`
+ // This field can have the runtime type of [map[string]map[string]string].
+ ProviderMetadata interface{} `json:"providerMetadata"`
+ Text string `json:"text"`
+ ToolUseID string `json:"toolUseId"`
+ JSON threadStreamEventThreadStreamContentMessageMessageContentJSON `json:"-"`
+ union ThreadStreamEventThreadStreamContentMessageMessageContentUnion
+}
+
+// threadStreamEventThreadStreamContentMessageMessageContentJSON contains the JSON
+// metadata for the struct
+// [ThreadStreamEventThreadStreamContentMessageMessageContent]
+type threadStreamEventThreadStreamContentMessageMessageContentJSON struct {
+ Type apijson.Field
+ ID apijson.Field
+ Content apijson.Field
+ DeniedByUser apijson.Field
+ Input apijson.Field
+ IsError apijson.Field
+ Name apijson.Field
+ ProviderMetadata apijson.Field
+ Text apijson.Field
+ ToolUseID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r threadStreamEventThreadStreamContentMessageMessageContentJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *ThreadStreamEventThreadStreamContentMessageMessageContent) UnmarshalJSON(data []byte) (err error) {
+ *r = ThreadStreamEventThreadStreamContentMessageMessageContent{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a
+// [ThreadStreamEventThreadStreamContentMessageMessageContentUnion] interface which
+// you can cast to the specific types for more type safety.
+//
+// Possible runtime types of the union are
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlock],
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlock],
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlock],
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlock],
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlock].
+func (r ThreadStreamEventThreadStreamContentMessageMessageContent) AsUnion() ThreadStreamEventThreadStreamContentMessageMessageContentUnion {
+ return r.union
+}
+
+// Union satisfied by
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlock],
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlock],
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlock],
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlock]
+// or
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlock].
+type ThreadStreamEventThreadStreamContentMessageMessageContentUnion interface {
+ implementsThreadStreamEventThreadStreamContentMessageMessageContent()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ThreadStreamEventThreadStreamContentMessageMessageContentUnion)(nil)).Elem(),
+ "type",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlock{}),
+ DiscriminatorValue: "text",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlock{}),
+ DiscriminatorValue: "tool_use",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlock{}),
+ DiscriminatorValue: "tool_result",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlock{}),
+ DiscriminatorValue: "server_tool_use",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlock{}),
+ DiscriminatorValue: "web_search_tool_result",
+ },
+ )
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlock struct {
+ Text string `json:"text" api:"required"`
+ Type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockType `json:"type" api:"required"`
+ ProviderMetadata map[string]map[string]string `json:"providerMetadata"`
+ JSON threadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockJSON
+// contains the JSON metadata for the struct
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlock]
+type threadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockJSON struct {
+ Text apijson.Field
+ Type apijson.Field
+ ProviderMetadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlock) implementsThreadStreamEventThreadStreamContentMessageMessageContent() {
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockType string
const (
- EventListForFleetParamsHistoryTrue EventListForFleetParamsHistory = "true"
- EventListForFleetParamsHistoryFalse EventListForFleetParamsHistory = "false"
+ ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockTypeText ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockType = "text"
)
-func (r EventListForFleetParamsHistory) IsKnown() bool {
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockType) IsKnown() bool {
switch r {
- case EventListForFleetParamsHistoryTrue, EventListForFleetParamsHistoryFalse:
+ case ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockTypeText:
return true
}
return false
}
-type EventListForThreadParams struct {
- // Opaque pagination cursor returned by a previous request.
- Cursor param.Field[string] `query:"cursor"`
- // Comma-separated event type filter.
- Events param.Field[string] `query:"events"`
- // When true, starts from the beginning of the retained buffer.
- History param.Field[EventListForThreadParamsHistory] `query:"history"`
- // Maximum number of items to return. Defaults to 20 and preserves parseInt
- // semantics.
- Limit param.Field[string] `query:"limit"`
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlock struct {
+ ID string `json:"id" api:"required"`
+ // JSON-serialized tool input payload. Parse as JSON before reading tool-specific
+ // fields.
+ Input string `json:"input" api:"required"`
+ Name shared.ToolName `json:"name" api:"required"`
+ Type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockType `json:"type" api:"required"`
+ ProviderMetadata map[string]map[string]string `json:"providerMetadata"`
+ JSON threadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockJSON `json:"-"`
}
-// URLQuery serializes [EventListForThreadParams]'s query parameters as
-// `url.Values`.
-func (r EventListForThreadParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
+// threadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockJSON
+// contains the JSON metadata for the struct
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlock]
+type threadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockJSON struct {
+ ID apijson.Field
+ Input apijson.Field
+ Name apijson.Field
+ Type apijson.Field
+ ProviderMetadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
}
-// When true, starts from the beginning of the retained buffer.
-type EventListForThreadParamsHistory string
+func (r *ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlock) implementsThreadStreamEventThreadStreamContentMessageMessageContent() {
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockType string
const (
- EventListForThreadParamsHistoryTrue EventListForThreadParamsHistory = "true"
- EventListForThreadParamsHistoryFalse EventListForThreadParamsHistory = "false"
+ ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockTypeToolUse ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockType = "tool_use"
)
-func (r EventListForThreadParamsHistory) IsKnown() bool {
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockType) IsKnown() bool {
switch r {
- case EventListForThreadParamsHistoryTrue, EventListForThreadParamsHistoryFalse:
+ case ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockTypeToolUse:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlock struct {
+ Content string `json:"content" api:"required"`
+ IsError bool `json:"isError" api:"required"`
+ ToolUseID string `json:"toolUseId" api:"required"`
+ Type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockType `json:"type" api:"required"`
+ DeniedByUser bool `json:"deniedByUser"`
+ ProviderMetadata map[string]map[string]string `json:"providerMetadata"`
+ JSON threadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockJSON
+// contains the JSON metadata for the struct
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlock]
+type threadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockJSON struct {
+ Content apijson.Field
+ IsError apijson.Field
+ ToolUseID apijson.Field
+ Type apijson.Field
+ DeniedByUser apijson.Field
+ ProviderMetadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlock) implementsThreadStreamEventThreadStreamContentMessageMessageContent() {
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockType string
+
+const (
+ ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockTypeToolResult ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockType = "tool_result"
+)
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolResultContentBlockTypeToolResult:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlock struct {
+ ID string `json:"id" api:"required"`
+ // JSON-serialized tool input payload. Parse as JSON before reading tool-specific
+ // fields.
+ Input string `json:"input" api:"required"`
+ Name string `json:"name" api:"required"`
+ Type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockType `json:"type" api:"required"`
+ ProviderMetadata map[string]map[string]string `json:"providerMetadata"`
+ JSON threadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockJSON
+// contains the JSON metadata for the struct
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlock]
+type threadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockJSON struct {
+ ID apijson.Field
+ Input apijson.Field
+ Name apijson.Field
+ Type apijson.Field
+ ProviderMetadata apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlock) implementsThreadStreamEventThreadStreamContentMessageMessageContent() {
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockType string
+
+const (
+ ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockTypeServerToolUse ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockType = "server_tool_use"
+)
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamServerToolUseContentBlockTypeServerToolUse:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlock struct {
+ // Web search result payload. The runtime returns either an array of web search
+ // results or an error object.
+ Content interface{} `json:"content" api:"required"`
+ ToolUseID string `json:"toolUseId" api:"required"`
+ Type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockJSON
+// contains the JSON metadata for the struct
+// [ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlock]
+type threadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockJSON struct {
+ Content apijson.Field
+ ToolUseID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlock) implementsThreadStreamEventThreadStreamContentMessageMessageContent() {
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockType string
+
+const (
+ ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockTypeWebSearchToolResult ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockType = "web_search_tool_result"
+)
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamWebSearchToolResultContentBlockTypeWebSearchToolResult:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageContentType string
+
+const (
+ ThreadStreamEventThreadStreamContentMessageMessageContentTypeText ThreadStreamEventThreadStreamContentMessageMessageContentType = "text"
+ ThreadStreamEventThreadStreamContentMessageMessageContentTypeToolUse ThreadStreamEventThreadStreamContentMessageMessageContentType = "tool_use"
+ ThreadStreamEventThreadStreamContentMessageMessageContentTypeToolResult ThreadStreamEventThreadStreamContentMessageMessageContentType = "tool_result"
+ ThreadStreamEventThreadStreamContentMessageMessageContentTypeServerToolUse ThreadStreamEventThreadStreamContentMessageMessageContentType = "server_tool_use"
+ ThreadStreamEventThreadStreamContentMessageMessageContentTypeWebSearchToolResult ThreadStreamEventThreadStreamContentMessageMessageContentType = "web_search_tool_result"
+)
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamContentMessageMessageContentTypeText, ThreadStreamEventThreadStreamContentMessageMessageContentTypeToolUse, ThreadStreamEventThreadStreamContentMessageMessageContentTypeToolResult, ThreadStreamEventThreadStreamContentMessageMessageContentTypeServerToolUse, ThreadStreamEventThreadStreamContentMessageMessageContentTypeWebSearchToolResult:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamContentMessageMessageRole string
+
+const (
+ ThreadStreamEventThreadStreamContentMessageMessageRoleUser ThreadStreamEventThreadStreamContentMessageMessageRole = "user"
+ ThreadStreamEventThreadStreamContentMessageMessageRoleAssistant ThreadStreamEventThreadStreamContentMessageMessageRole = "assistant"
+)
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageRole) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamContentMessageMessageRoleUser, ThreadStreamEventThreadStreamContentMessageMessageRoleAssistant:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamContentMessageType string
+
+const (
+ ThreadStreamEventThreadStreamContentMessageTypeMessage ThreadStreamEventThreadStreamContentMessageType = "message"
+)
+
+func (r ThreadStreamEventThreadStreamContentMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamContentMessageTypeMessage:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamProgressMessage struct {
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ MessageCount float64 `json:"messageCount" api:"required"`
+ StepCount float64 `json:"stepCount" api:"required"`
+ StepSeq float64 `json:"stepSeq" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventThreadStreamProgressMessageType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamProgressMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamProgressMessageJSON contains the JSON metadata for
+// the struct [ThreadStreamEventThreadStreamProgressMessage]
+type threadStreamEventThreadStreamProgressMessageJSON struct {
+ EventSeq apijson.Field
+ MessageCount apijson.Field
+ StepCount apijson.Field
+ StepSeq apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamProgressMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamProgressMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamProgressMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamProgressMessageType string
+
+const (
+ ThreadStreamEventThreadStreamProgressMessageTypeProgress ThreadStreamEventThreadStreamProgressMessageType = "progress"
+)
+
+func (r ThreadStreamEventThreadStreamProgressMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamProgressMessageTypeProgress:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamTurnStartedMessage struct {
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ TurnSeq float64 `json:"turnSeq" api:"required"`
+ Type ThreadStreamEventThreadStreamTurnStartedMessageType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamTurnStartedMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamTurnStartedMessageJSON contains the JSON metadata
+// for the struct [ThreadStreamEventThreadStreamTurnStartedMessage]
+type threadStreamEventThreadStreamTurnStartedMessageJSON struct {
+ EventSeq apijson.Field
+ TurnID apijson.Field
+ TurnSeq apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamTurnStartedMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamTurnStartedMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamTurnStartedMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamTurnStartedMessageType string
+
+const (
+ ThreadStreamEventThreadStreamTurnStartedMessageTypeTurnStarted ThreadStreamEventThreadStreamTurnStartedMessageType = "turn/started"
+)
+
+func (r ThreadStreamEventThreadStreamTurnStartedMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamTurnStartedMessageTypeTurnStarted:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamTurnCompletedMessage struct {
+ Error string `json:"error" api:"required,nullable"`
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ Result string `json:"result" api:"required,nullable"`
+ Status ThreadStreamEventThreadStreamTurnCompletedMessageStatus `json:"status" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ TurnSeq float64 `json:"turnSeq" api:"required"`
+ Type ThreadStreamEventThreadStreamTurnCompletedMessageType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamTurnCompletedMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamTurnCompletedMessageJSON contains the JSON metadata
+// for the struct [ThreadStreamEventThreadStreamTurnCompletedMessage]
+type threadStreamEventThreadStreamTurnCompletedMessageJSON struct {
+ Error apijson.Field
+ EventSeq apijson.Field
+ Result apijson.Field
+ Status apijson.Field
+ TurnID apijson.Field
+ TurnSeq apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamTurnCompletedMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamTurnCompletedMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamTurnCompletedMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamTurnCompletedMessageStatus string
+
+const (
+ ThreadStreamEventThreadStreamTurnCompletedMessageStatusCompleted ThreadStreamEventThreadStreamTurnCompletedMessageStatus = "completed"
+ ThreadStreamEventThreadStreamTurnCompletedMessageStatusFailed ThreadStreamEventThreadStreamTurnCompletedMessageStatus = "failed"
+)
+
+func (r ThreadStreamEventThreadStreamTurnCompletedMessageStatus) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamTurnCompletedMessageStatusCompleted, ThreadStreamEventThreadStreamTurnCompletedMessageStatusFailed:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamTurnCompletedMessageType string
+
+const (
+ ThreadStreamEventThreadStreamTurnCompletedMessageTypeTurnCompleted ThreadStreamEventThreadStreamTurnCompletedMessageType = "turn/completed"
+)
+
+func (r ThreadStreamEventThreadStreamTurnCompletedMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamTurnCompletedMessageTypeTurnCompleted:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamItemStartedMessage struct {
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ ItemID string `json:"itemId" api:"required"`
+ ItemType ThreadStreamEventThreadStreamItemStartedMessageItemType `json:"itemType" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventThreadStreamItemStartedMessageType `json:"type" api:"required"`
+ RequestedToolName string `json:"requestedToolName"`
+ SubThreadID string `json:"subThreadId"`
+ ToolName shared.ToolName `json:"toolName"`
+ JSON threadStreamEventThreadStreamItemStartedMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamItemStartedMessageJSON contains the JSON metadata
+// for the struct [ThreadStreamEventThreadStreamItemStartedMessage]
+type threadStreamEventThreadStreamItemStartedMessageJSON struct {
+ EventSeq apijson.Field
+ ItemID apijson.Field
+ ItemType apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ RequestedToolName apijson.Field
+ SubThreadID apijson.Field
+ ToolName apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamItemStartedMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamItemStartedMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamItemStartedMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamItemStartedMessageItemType string
+
+const (
+ ThreadStreamEventThreadStreamItemStartedMessageItemTypeToolCall ThreadStreamEventThreadStreamItemStartedMessageItemType = "tool_call"
+ ThreadStreamEventThreadStreamItemStartedMessageItemTypeAgentMessage ThreadStreamEventThreadStreamItemStartedMessageItemType = "agent_message"
+ ThreadStreamEventThreadStreamItemStartedMessageItemTypeLlmCall ThreadStreamEventThreadStreamItemStartedMessageItemType = "llm_call"
+ ThreadStreamEventThreadStreamItemStartedMessageItemTypeSubThread ThreadStreamEventThreadStreamItemStartedMessageItemType = "sub_thread"
+)
+
+func (r ThreadStreamEventThreadStreamItemStartedMessageItemType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamItemStartedMessageItemTypeToolCall, ThreadStreamEventThreadStreamItemStartedMessageItemTypeAgentMessage, ThreadStreamEventThreadStreamItemStartedMessageItemTypeLlmCall, ThreadStreamEventThreadStreamItemStartedMessageItemTypeSubThread:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamItemStartedMessageType string
+
+const (
+ ThreadStreamEventThreadStreamItemStartedMessageTypeItemStarted ThreadStreamEventThreadStreamItemStartedMessageType = "item/started"
+)
+
+func (r ThreadStreamEventThreadStreamItemStartedMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamItemStartedMessageTypeItemStarted:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamItemCompletedMessage struct {
+ DurationMs float64 `json:"durationMs" api:"required"`
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ ItemID string `json:"itemId" api:"required"`
+ ItemType ThreadStreamEventThreadStreamItemCompletedMessageItemType `json:"itemType" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventThreadStreamItemCompletedMessageType `json:"type" api:"required"`
+ IsError bool `json:"isError"`
+ RequestedToolName string `json:"requestedToolName"`
+ JSON threadStreamEventThreadStreamItemCompletedMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamItemCompletedMessageJSON contains the JSON metadata
+// for the struct [ThreadStreamEventThreadStreamItemCompletedMessage]
+type threadStreamEventThreadStreamItemCompletedMessageJSON struct {
+ DurationMs apijson.Field
+ EventSeq apijson.Field
+ ItemID apijson.Field
+ ItemType apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ IsError apijson.Field
+ RequestedToolName apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamItemCompletedMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamItemCompletedMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamItemCompletedMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamItemCompletedMessageItemType string
+
+const (
+ ThreadStreamEventThreadStreamItemCompletedMessageItemTypeToolCall ThreadStreamEventThreadStreamItemCompletedMessageItemType = "tool_call"
+ ThreadStreamEventThreadStreamItemCompletedMessageItemTypeAgentMessage ThreadStreamEventThreadStreamItemCompletedMessageItemType = "agent_message"
+ ThreadStreamEventThreadStreamItemCompletedMessageItemTypeLlmCall ThreadStreamEventThreadStreamItemCompletedMessageItemType = "llm_call"
+ ThreadStreamEventThreadStreamItemCompletedMessageItemTypeSubThread ThreadStreamEventThreadStreamItemCompletedMessageItemType = "sub_thread"
+)
+
+func (r ThreadStreamEventThreadStreamItemCompletedMessageItemType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamItemCompletedMessageItemTypeToolCall, ThreadStreamEventThreadStreamItemCompletedMessageItemTypeAgentMessage, ThreadStreamEventThreadStreamItemCompletedMessageItemTypeLlmCall, ThreadStreamEventThreadStreamItemCompletedMessageItemTypeSubThread:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamItemCompletedMessageType string
+
+const (
+ ThreadStreamEventThreadStreamItemCompletedMessageTypeItemCompleted ThreadStreamEventThreadStreamItemCompletedMessageType = "item/completed"
+)
+
+func (r ThreadStreamEventThreadStreamItemCompletedMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamItemCompletedMessageTypeItemCompleted:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamTokenUsageMessage struct {
+ CumulativeInputTokens float64 `json:"cumulativeInputTokens" api:"required"`
+ CumulativeOutputTokens float64 `json:"cumulativeOutputTokens" api:"required"`
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ InputTokens float64 `json:"inputTokens" api:"required"`
+ OutputTokens float64 `json:"outputTokens" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventThreadStreamTokenUsageMessageType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamTokenUsageMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamTokenUsageMessageJSON contains the JSON metadata
+// for the struct [ThreadStreamEventThreadStreamTokenUsageMessage]
+type threadStreamEventThreadStreamTokenUsageMessageJSON struct {
+ CumulativeInputTokens apijson.Field
+ CumulativeOutputTokens apijson.Field
+ EventSeq apijson.Field
+ InputTokens apijson.Field
+ OutputTokens apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamTokenUsageMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamTokenUsageMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamTokenUsageMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamTokenUsageMessageType string
+
+const (
+ ThreadStreamEventThreadStreamTokenUsageMessageTypeTokenUsage ThreadStreamEventThreadStreamTokenUsageMessageType = "token_usage"
+)
+
+func (r ThreadStreamEventThreadStreamTokenUsageMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamTokenUsageMessageTypeTokenUsage:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamApprovalRequestedMessage struct {
+ Approval ThreadStreamEventThreadStreamApprovalRequestedMessageApproval `json:"approval" api:"required"`
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventThreadStreamApprovalRequestedMessageType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamApprovalRequestedMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamApprovalRequestedMessageJSON contains the JSON
+// metadata for the struct [ThreadStreamEventThreadStreamApprovalRequestedMessage]
+type threadStreamEventThreadStreamApprovalRequestedMessageJSON struct {
+ Approval apijson.Field
+ EventSeq apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamApprovalRequestedMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamApprovalRequestedMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamApprovalRequestedMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamApprovalRequestedMessageApproval struct {
+ ID string `json:"id" api:"required"`
+ CreatedAt string `json:"createdAt" api:"required"`
+ RequestedToolName string `json:"requestedToolName" api:"required"`
+ ResolvedAt string `json:"resolvedAt" api:"required,nullable"`
+ Status ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatus `json:"status" api:"required"`
+ ThreadID string `json:"threadId" api:"required"`
+ TimeoutAt string `json:"timeoutAt" api:"required,nullable"`
+ TimeoutMs float64 `json:"timeoutMs" api:"required,nullable"`
+ ToolIndex float64 `json:"toolIndex" api:"required"`
+ // JSON-serialized tool input payload. Parse as JSON before reading tool-specific
+ // fields.
+ ToolInput string `json:"toolInput" api:"required"`
+ ToolName shared.ToolName `json:"toolName" api:"required"`
+ ToolUseID string `json:"toolUseId" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ ToolSourceID string `json:"toolSourceId"`
+ ToolSourceVersion float64 `json:"toolSourceVersion"`
+ JSON threadStreamEventThreadStreamApprovalRequestedMessageApprovalJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamApprovalRequestedMessageApprovalJSON contains the
+// JSON metadata for the struct
+// [ThreadStreamEventThreadStreamApprovalRequestedMessageApproval]
+type threadStreamEventThreadStreamApprovalRequestedMessageApprovalJSON struct {
+ ID apijson.Field
+ CreatedAt apijson.Field
+ RequestedToolName apijson.Field
+ ResolvedAt apijson.Field
+ Status apijson.Field
+ ThreadID apijson.Field
+ TimeoutAt apijson.Field
+ TimeoutMs apijson.Field
+ ToolIndex apijson.Field
+ ToolInput apijson.Field
+ ToolName apijson.Field
+ ToolUseID apijson.Field
+ TurnID apijson.Field
+ ToolSourceID apijson.Field
+ ToolSourceVersion apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamApprovalRequestedMessageApproval) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamApprovalRequestedMessageApprovalJSON) RawJSON() string {
+ return r.raw
+}
+
+type ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatus string
+
+const (
+ ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusPending ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatus = "pending"
+ ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusApproved ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatus = "approved"
+ ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusDenied ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatus = "denied"
+ ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusCancelled ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatus = "cancelled"
+ ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusTimedOut ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatus = "timed_out"
+)
+
+func (r ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatus) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusPending, ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusApproved, ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusDenied, ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusCancelled, ThreadStreamEventThreadStreamApprovalRequestedMessageApprovalStatusTimedOut:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamApprovalRequestedMessageType string
+
+const (
+ ThreadStreamEventThreadStreamApprovalRequestedMessageTypeApprovalRequested ThreadStreamEventThreadStreamApprovalRequestedMessageType = "approval/requested"
+)
+
+func (r ThreadStreamEventThreadStreamApprovalRequestedMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamApprovalRequestedMessageTypeApprovalRequested:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamApprovalResolvedMessage struct {
+ ApprovalID string `json:"approvalId" api:"required"`
+ Decision ThreadStreamEventThreadStreamApprovalResolvedMessageDecision `json:"decision" api:"required"`
+ EventSeq float64 `json:"eventSeq" api:"required"`
+ TurnID string `json:"turnId" api:"required"`
+ Type ThreadStreamEventThreadStreamApprovalResolvedMessageType `json:"type" api:"required"`
+ JSON threadStreamEventThreadStreamApprovalResolvedMessageJSON `json:"-"`
+}
+
+// threadStreamEventThreadStreamApprovalResolvedMessageJSON contains the JSON
+// metadata for the struct [ThreadStreamEventThreadStreamApprovalResolvedMessage]
+type threadStreamEventThreadStreamApprovalResolvedMessageJSON struct {
+ ApprovalID apijson.Field
+ Decision apijson.Field
+ EventSeq apijson.Field
+ TurnID apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ThreadStreamEventThreadStreamApprovalResolvedMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r threadStreamEventThreadStreamApprovalResolvedMessageJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r ThreadStreamEventThreadStreamApprovalResolvedMessage) implementsThreadStreamEvent() {}
+
+type ThreadStreamEventThreadStreamApprovalResolvedMessageDecision string
+
+const (
+ ThreadStreamEventThreadStreamApprovalResolvedMessageDecisionApprove ThreadStreamEventThreadStreamApprovalResolvedMessageDecision = "approve"
+ ThreadStreamEventThreadStreamApprovalResolvedMessageDecisionDeny ThreadStreamEventThreadStreamApprovalResolvedMessageDecision = "deny"
+ ThreadStreamEventThreadStreamApprovalResolvedMessageDecisionCancel ThreadStreamEventThreadStreamApprovalResolvedMessageDecision = "cancel"
+ ThreadStreamEventThreadStreamApprovalResolvedMessageDecisionTimeout ThreadStreamEventThreadStreamApprovalResolvedMessageDecision = "timeout"
+)
+
+func (r ThreadStreamEventThreadStreamApprovalResolvedMessageDecision) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamApprovalResolvedMessageDecisionApprove, ThreadStreamEventThreadStreamApprovalResolvedMessageDecisionDeny, ThreadStreamEventThreadStreamApprovalResolvedMessageDecisionCancel, ThreadStreamEventThreadStreamApprovalResolvedMessageDecisionTimeout:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventThreadStreamApprovalResolvedMessageType string
+
+const (
+ ThreadStreamEventThreadStreamApprovalResolvedMessageTypeApprovalResolved ThreadStreamEventThreadStreamApprovalResolvedMessageType = "approval/resolved"
+)
+
+func (r ThreadStreamEventThreadStreamApprovalResolvedMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamApprovalResolvedMessageTypeApprovalResolved:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventType string
+
+const (
+ ThreadStreamEventTypeStatus ThreadStreamEventType = "status"
+ ThreadStreamEventTypeMessage ThreadStreamEventType = "message"
+ ThreadStreamEventTypeProgress ThreadStreamEventType = "progress"
+ ThreadStreamEventTypeTurnStarted ThreadStreamEventType = "turn/started"
+ ThreadStreamEventTypeTurnCompleted ThreadStreamEventType = "turn/completed"
+ ThreadStreamEventTypeItemStarted ThreadStreamEventType = "item/started"
+ ThreadStreamEventTypeItemCompleted ThreadStreamEventType = "item/completed"
+ ThreadStreamEventTypeTokenUsage ThreadStreamEventType = "token_usage"
+ ThreadStreamEventTypeApprovalRequested ThreadStreamEventType = "approval/requested"
+ ThreadStreamEventTypeApprovalResolved ThreadStreamEventType = "approval/resolved"
+)
+
+func (r ThreadStreamEventType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventTypeStatus, ThreadStreamEventTypeMessage, ThreadStreamEventTypeProgress, ThreadStreamEventTypeTurnStarted, ThreadStreamEventTypeTurnCompleted, ThreadStreamEventTypeItemStarted, ThreadStreamEventTypeItemCompleted, ThreadStreamEventTypeTokenUsage, ThreadStreamEventTypeApprovalRequested, ThreadStreamEventTypeApprovalResolved:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventDecision string
+
+const (
+ ThreadStreamEventDecisionApprove ThreadStreamEventDecision = "approve"
+ ThreadStreamEventDecisionDeny ThreadStreamEventDecision = "deny"
+ ThreadStreamEventDecisionCancel ThreadStreamEventDecision = "cancel"
+ ThreadStreamEventDecisionTimeout ThreadStreamEventDecision = "timeout"
+)
+
+func (r ThreadStreamEventDecision) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventDecisionApprove, ThreadStreamEventDecisionDeny, ThreadStreamEventDecisionCancel, ThreadStreamEventDecisionTimeout:
+ return true
+ }
+ return false
+}
+
+type ThreadStreamEventItemType string
+
+const (
+ ThreadStreamEventItemTypeToolCall ThreadStreamEventItemType = "tool_call"
+ ThreadStreamEventItemTypeAgentMessage ThreadStreamEventItemType = "agent_message"
+ ThreadStreamEventItemTypeLlmCall ThreadStreamEventItemType = "llm_call"
+ ThreadStreamEventItemTypeSubThread ThreadStreamEventItemType = "sub_thread"
+)
+
+func (r ThreadStreamEventItemType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventItemTypeToolCall, ThreadStreamEventItemTypeAgentMessage, ThreadStreamEventItemTypeLlmCall, ThreadStreamEventItemTypeSubThread:
+ return true
+ }
+ return false
+}
+
+type EventListForAgentParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventListForAgentParamsHistory] `query:"history"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [EventListForAgentParams]'s query parameters as
+// `url.Values`.
+func (r EventListForAgentParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventListForAgentParamsHistory string
+
+const (
+ EventListForAgentParamsHistoryTrue EventListForAgentParamsHistory = "true"
+ EventListForAgentParamsHistoryFalse EventListForAgentParamsHistory = "false"
+)
+
+func (r EventListForAgentParamsHistory) IsKnown() bool {
+ switch r {
+ case EventListForAgentParamsHistoryTrue, EventListForAgentParamsHistoryFalse:
+ return true
+ }
+ return false
+}
+
+type EventListForFleetParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventListForFleetParamsHistory] `query:"history"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [EventListForFleetParams]'s query parameters as
+// `url.Values`.
+func (r EventListForFleetParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventListForFleetParamsHistory string
+
+const (
+ EventListForFleetParamsHistoryTrue EventListForFleetParamsHistory = "true"
+ EventListForFleetParamsHistoryFalse EventListForFleetParamsHistory = "false"
+)
+
+func (r EventListForFleetParamsHistory) IsKnown() bool {
+ switch r {
+ case EventListForFleetParamsHistoryTrue, EventListForFleetParamsHistoryFalse:
+ return true
+ }
+ return false
+}
+
+type EventListForThreadParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventListForThreadParamsHistory] `query:"history"`
+ // Maximum number of items to return. Defaults to 20 and preserves parseInt
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+}
+
+// URLQuery serializes [EventListForThreadParams]'s query parameters as
+// `url.Values`.
+func (r EventListForThreadParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventListForThreadParamsHistory string
+
+const (
+ EventListForThreadParamsHistoryTrue EventListForThreadParamsHistory = "true"
+ EventListForThreadParamsHistoryFalse EventListForThreadParamsHistory = "false"
+)
+
+func (r EventListForThreadParamsHistory) IsKnown() bool {
+ switch r {
+ case EventListForThreadParamsHistoryTrue, EventListForThreadParamsHistoryFalse:
+ return true
+ }
+ return false
+}
+
+type EventStreamForAgentParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventStreamForAgentParamsHistory] `query:"history"`
+ // Resume an event-log stream after the last received SSE event id.
+ LastEventID param.Field[string] `header:"Last-Event-ID"`
+}
+
+// URLQuery serializes [EventStreamForAgentParams]'s query parameters as
+// `url.Values`.
+func (r EventStreamForAgentParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventStreamForAgentParamsHistory string
+
+const (
+ EventStreamForAgentParamsHistoryTrue EventStreamForAgentParamsHistory = "true"
+ EventStreamForAgentParamsHistoryFalse EventStreamForAgentParamsHistory = "false"
+)
+
+func (r EventStreamForAgentParamsHistory) IsKnown() bool {
+ switch r {
+ case EventStreamForAgentParamsHistoryTrue, EventStreamForAgentParamsHistoryFalse:
+ return true
+ }
+ return false
+}
+
+type EventStreamForFleetParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventStreamForFleetParamsHistory] `query:"history"`
+ // Resume an event-log stream after the last received SSE event id.
+ LastEventID param.Field[string] `header:"Last-Event-ID"`
+}
+
+// URLQuery serializes [EventStreamForFleetParams]'s query parameters as
+// `url.Values`.
+func (r EventStreamForFleetParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventStreamForFleetParamsHistory string
+
+const (
+ EventStreamForFleetParamsHistoryTrue EventStreamForFleetParamsHistory = "true"
+ EventStreamForFleetParamsHistoryFalse EventStreamForFleetParamsHistory = "false"
+)
+
+func (r EventStreamForFleetParamsHistory) IsKnown() bool {
+ switch r {
+ case EventStreamForFleetParamsHistoryTrue, EventStreamForFleetParamsHistoryFalse:
+ return true
+ }
+ return false
+}
+
+type EventStreamForThreadEventsParams struct {
+ // Opaque pagination cursor returned by a previous request.
+ Cursor param.Field[string] `query:"cursor"`
+ // Comma-separated event type filter.
+ Events param.Field[string] `query:"events"`
+ // When true, starts from the beginning of the retained buffer.
+ History param.Field[EventStreamForThreadEventsParamsHistory] `query:"history"`
+ // Resume an event-log stream after the last received SSE event id.
+ LastEventID param.Field[string] `header:"Last-Event-ID"`
+}
+
+// URLQuery serializes [EventStreamForThreadEventsParams]'s query parameters as
+// `url.Values`.
+func (r EventStreamForThreadEventsParams) URLQuery() (v url.Values) {
+ return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
+ ArrayFormat: apiquery.ArrayQueryFormatComma,
+ NestedFormat: apiquery.NestedQueryFormatBrackets,
+ })
+}
+
+// When true, starts from the beginning of the retained buffer.
+type EventStreamForThreadEventsParamsHistory string
+
+const (
+ EventStreamForThreadEventsParamsHistoryTrue EventStreamForThreadEventsParamsHistory = "true"
+ EventStreamForThreadEventsParamsHistoryFalse EventStreamForThreadEventsParamsHistory = "false"
+)
+
+func (r EventStreamForThreadEventsParamsHistory) IsKnown() bool {
+ switch r {
+ case EventStreamForThreadEventsParamsHistoryTrue, EventStreamForThreadEventsParamsHistoryFalse:
return true
}
return false
diff --git a/event_test.go b/event_test.go
index 058eff0..814aae7 100644
--- a/event_test.go
+++ b/event_test.go
@@ -106,73 +106,3 @@ func TestEventListForThreadWithOptionalParams(t *testing.T) {
t.Fatalf("err should be nil: %s", err.Error())
}
}
-
-func TestEventSubscribeAgent(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Events.SubscribeAgent(context.TODO(), "agent_abc123")
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestEventSubscribeFleet(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Events.SubscribeFleet(context.TODO(), "fleet_abc123")
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
-
-func TestEventSubscribeThread(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
- client := cercago.NewClient(
- option.WithBaseURL(baseURL),
- option.WithAPIKey("My API Key"),
- )
- _, err := client.Events.SubscribeThread(
- context.TODO(),
- "agent_abc123",
- "thread_abc123",
- )
- if err != nil {
- var apierr *cercago.Error
- if errors.As(err, &apierr) {
- t.Log(string(apierr.DumpRequest(true)))
- }
- t.Fatalf("err should be nil: %s", err.Error())
- }
-}
diff --git a/packages/ssestream/ssestream.go b/packages/ssestream/ssestream.go
new file mode 100644
index 0000000..895ed81
--- /dev/null
+++ b/packages/ssestream/ssestream.go
@@ -0,0 +1,192 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package ssestream
+
+import (
+ "bufio"
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "strings"
+)
+
+type Decoder interface {
+ Event() Event
+ Next() bool
+ Close() error
+ Err() error
+}
+
+func NewDecoder(res *http.Response) Decoder {
+ if res == nil || res.Body == nil {
+ return nil
+ }
+
+ var decoder Decoder
+ contentType := res.Header.Get("content-type")
+ if t, ok := decoderTypes[contentType]; ok {
+ decoder = t(res.Body)
+ } else {
+ scn := bufio.NewScanner(res.Body)
+ scn.Buffer(nil, bufio.MaxScanTokenSize<<9)
+ decoder = &eventStreamDecoder{rc: res.Body, scn: scn}
+ }
+ return decoder
+}
+
+var decoderTypes = map[string](func(io.ReadCloser) Decoder){}
+
+func RegisterDecoder(contentType string, decoder func(io.ReadCloser) Decoder) {
+ decoderTypes[strings.ToLower(contentType)] = decoder
+}
+
+type Event struct {
+ Type string
+ Data []byte
+}
+
+// A base implementation of a Decoder for text/event-stream.
+type eventStreamDecoder struct {
+ evt Event
+ rc io.ReadCloser
+ scn *bufio.Scanner
+ err error
+}
+
+func (s *eventStreamDecoder) Next() bool {
+ if s.err != nil {
+ return false
+ }
+
+ event := ""
+ data := bytes.NewBuffer(nil)
+
+ for s.scn.Scan() {
+ txt := s.scn.Bytes()
+
+ // Dispatch event on an empty line
+ if len(txt) == 0 {
+ s.evt = Event{
+ Type: event,
+ Data: data.Bytes(),
+ }
+ return true
+ }
+
+ // Split a string like "event: bar" into name="event" and value=" bar".
+ name, value, _ := bytes.Cut(txt, []byte(":"))
+
+ // Consume an optional space after the colon if it exists.
+ if len(value) > 0 && value[0] == ' ' {
+ value = value[1:]
+ }
+
+ switch string(name) {
+ case "":
+ // An empty line in the for ": something" is a comment and should be ignored.
+ continue
+ case "event":
+ event = string(value)
+ case "data":
+ _, s.err = data.Write(value)
+ if s.err != nil {
+ break
+ }
+ _, s.err = data.WriteRune('\n')
+ if s.err != nil {
+ break
+ }
+ }
+ }
+
+ if s.scn.Err() != nil {
+ s.err = s.scn.Err()
+ }
+
+ return false
+}
+
+func (s *eventStreamDecoder) Event() Event {
+ return s.evt
+}
+
+func (s *eventStreamDecoder) Close() error {
+ return s.rc.Close()
+}
+
+func (s *eventStreamDecoder) Err() error {
+ return s.err
+}
+
+type Stream[T any] struct {
+ decoder Decoder
+ cur T
+ err error
+}
+
+func NewStream[T any](decoder Decoder, err error) *Stream[T] {
+ return &Stream[T]{
+ decoder: decoder,
+ err: err,
+ }
+}
+
+// Next returns false if the stream has ended or an error occurred.
+// Call Stream.Current() to get the current value.
+// Call Stream.Err() to get the error.
+//
+// for stream.Next() {
+// data := stream.Current()
+// }
+//
+// if stream.Err() != nil {
+// ...
+// }
+func (s *Stream[T]) Next() bool {
+ if s.err != nil {
+ return false
+ }
+
+ for s.decoder.Next() {
+ switch s.decoder.Event().Type {
+ case "error":
+ s.err = fmt.Errorf("received error while streaming: %s", string(s.decoder.Event().Data))
+ return false
+ case "overflow":
+ continue
+ case "ping", "hb":
+ continue
+ }
+
+ var nxt T
+ s.err = json.Unmarshal(s.decoder.Event().Data, &nxt)
+ if s.err != nil {
+ return false
+ }
+ s.cur = nxt
+ return true
+ }
+
+ // decoder.Next() may be false because of an error
+ s.err = s.decoder.Err()
+
+ return false
+}
+
+func (s *Stream[T]) Current() T {
+ return s.cur
+}
+
+func (s *Stream[T]) Err() error {
+ return s.err
+}
+
+func (s *Stream[T]) Close() error {
+ if s.decoder == nil {
+ // already closed
+ return nil
+ }
+ return s.decoder.Close()
+}
diff --git a/shared/shared.go b/shared/shared.go
index 56671f6..cad30fe 100644
--- a/shared/shared.go
+++ b/shared/shared.go
@@ -2,10 +2,6 @@
package shared
-import (
- "github.com/matrices/cerca-go/internal/apijson"
-)
-
type ApprovalMode string
const (
@@ -21,31 +17,6 @@ func (r ApprovalMode) IsKnown() bool {
return false
}
-type ErrorResponse struct {
- Error string `json:"error" api:"required"`
- // Stable machine-readable error code when the API can provide one.
- Code string `json:"code"`
- JSON errorResponseJSON `json:"-"`
-}
-
-// errorResponseJSON contains the JSON metadata for the struct [ErrorResponse]
-type errorResponseJSON struct {
- Error apijson.Field
- Code apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ErrorResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r errorResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type JsonObject map[string]interface{}
-
type ToolName string
const (
diff --git a/tool.go b/tool.go
index 7eea2de..15f092c 100644
--- a/tool.go
+++ b/tool.go
@@ -127,6 +127,63 @@ func (r *ToolService) Delete(ctx context.Context, fleetID string, sourceID strin
return err
}
+type APIKeyToolSourceAuth struct {
+ ConnectionID string `json:"connectionId" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject AuthInjection `json:"inject" api:"required"`
+ Kind APIKeyToolSourceAuthKind `json:"kind" api:"required"`
+ JSON apiKeyToolSourceAuthJSON `json:"-"`
+}
+
+// apiKeyToolSourceAuthJSON contains the JSON metadata for the struct
+// [APIKeyToolSourceAuth]
+type apiKeyToolSourceAuthJSON struct {
+ ConnectionID apijson.Field
+ Inject apijson.Field
+ Kind apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *APIKeyToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r apiKeyToolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r APIKeyToolSourceAuth) implementsToolSourceAuth() {}
+
+type APIKeyToolSourceAuthKind string
+
+const (
+ APIKeyToolSourceAuthKindAPIKey APIKeyToolSourceAuthKind = "api_key"
+)
+
+func (r APIKeyToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case APIKeyToolSourceAuthKindAPIKey:
+ return true
+ }
+ return false
+}
+
+type APIKeyToolSourceAuthParam struct {
+ ConnectionID param.Field[string] `json:"connectionId" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject param.Field[AuthInjectionUnionParam] `json:"inject" api:"required"`
+ Kind param.Field[APIKeyToolSourceAuthKind] `json:"kind" api:"required"`
+}
+
+func (r APIKeyToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r APIKeyToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
// Where an API key or OAuth access token should be injected into outgoing
// tool-source requests.
type AuthInjection struct {
@@ -711,6 +768,113 @@ func (r McpToolSourceType) IsKnown() bool {
return false
}
+type NoToolSourceAuth struct {
+ Kind NoToolSourceAuthKind `json:"kind" api:"required"`
+ JSON noToolSourceAuthJSON `json:"-"`
+}
+
+// noToolSourceAuthJSON contains the JSON metadata for the struct
+// [NoToolSourceAuth]
+type noToolSourceAuthJSON struct {
+ Kind apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *NoToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r noToolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r NoToolSourceAuth) implementsToolSourceAuth() {}
+
+type NoToolSourceAuthKind string
+
+const (
+ NoToolSourceAuthKindNone NoToolSourceAuthKind = "none"
+)
+
+func (r NoToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case NoToolSourceAuthKindNone:
+ return true
+ }
+ return false
+}
+
+type NoToolSourceAuthParam struct {
+ Kind param.Field[NoToolSourceAuthKind] `json:"kind" api:"required"`
+}
+
+func (r NoToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r NoToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
+type OAuthConnectionToolSourceAuth struct {
+ Kind OAuthConnectionToolSourceAuthKind `json:"kind" api:"required"`
+ Provider string `json:"provider" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject AuthInjection `json:"inject"`
+ RequiredScopes []string `json:"requiredScopes"`
+ JSON oauthConnectionToolSourceAuthJSON `json:"-"`
+}
+
+// oauthConnectionToolSourceAuthJSON contains the JSON metadata for the struct
+// [OAuthConnectionToolSourceAuth]
+type oauthConnectionToolSourceAuthJSON struct {
+ Kind apijson.Field
+ Provider apijson.Field
+ Inject apijson.Field
+ RequiredScopes apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *OAuthConnectionToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r oauthConnectionToolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r OAuthConnectionToolSourceAuth) implementsToolSourceAuth() {}
+
+type OAuthConnectionToolSourceAuthKind string
+
+const (
+ OAuthConnectionToolSourceAuthKindOAuthConnection OAuthConnectionToolSourceAuthKind = "oauth_connection"
+)
+
+func (r OAuthConnectionToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case OAuthConnectionToolSourceAuthKindOAuthConnection:
+ return true
+ }
+ return false
+}
+
+type OAuthConnectionToolSourceAuthParam struct {
+ Kind param.Field[OAuthConnectionToolSourceAuthKind] `json:"kind" api:"required"`
+ Provider param.Field[string] `json:"provider" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject param.Field[AuthInjectionUnionParam] `json:"inject"`
+ RequiredScopes param.Field[[]string] `json:"requiredScopes"`
+}
+
+func (r OAuthConnectionToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r OAuthConnectionToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
// Source-owned OAuth exchange configuration. Public schemas use connection IDs for
// stored client secrets and assertions.
type OAuthExchangeConfig struct {
@@ -975,6 +1139,67 @@ func (r OAuthExchangeConfigJwtBearerOAuthExchangeParam) MarshalJSON() (data []by
func (r OAuthExchangeConfigJwtBearerOAuthExchangeParam) implementsOAuthExchangeConfigUnionParam() {}
+type OAuthExchangeToolSourceAuth struct {
+ // Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+ // stored client secrets and assertions.
+ Exchange OAuthExchangeConfig `json:"exchange" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject AuthInjection `json:"inject" api:"required"`
+ Kind OAuthExchangeToolSourceAuthKind `json:"kind" api:"required"`
+ JSON oauthExchangeToolSourceAuthJSON `json:"-"`
+}
+
+// oauthExchangeToolSourceAuthJSON contains the JSON metadata for the struct
+// [OAuthExchangeToolSourceAuth]
+type oauthExchangeToolSourceAuthJSON struct {
+ Exchange apijson.Field
+ Inject apijson.Field
+ Kind apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *OAuthExchangeToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r oauthExchangeToolSourceAuthJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r OAuthExchangeToolSourceAuth) implementsToolSourceAuth() {}
+
+type OAuthExchangeToolSourceAuthKind string
+
+const (
+ OAuthExchangeToolSourceAuthKindOAuthExchange OAuthExchangeToolSourceAuthKind = "oauth_exchange"
+)
+
+func (r OAuthExchangeToolSourceAuthKind) IsKnown() bool {
+ switch r {
+ case OAuthExchangeToolSourceAuthKindOAuthExchange:
+ return true
+ }
+ return false
+}
+
+type OAuthExchangeToolSourceAuthParam struct {
+ // Source-owned OAuth exchange configuration. Public schemas use connection IDs for
+ // stored client secrets and assertions.
+ Exchange param.Field[OAuthExchangeConfigUnionParam] `json:"exchange" api:"required"`
+ // Where an API key or OAuth access token should be injected into outgoing
+ // tool-source requests.
+ Inject param.Field[AuthInjectionUnionParam] `json:"inject" api:"required"`
+ Kind param.Field[OAuthExchangeToolSourceAuthKind] `json:"kind" api:"required"`
+}
+
+func (r OAuthExchangeToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r OAuthExchangeToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
+
// How the HTTP response should be normalized for the agent.
type ResponseNormalizationHint struct {
Mode ResponseNormalizationHintMode `json:"mode" api:"required"`
@@ -1184,10 +1409,9 @@ func (r *ToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
// AsUnion returns a [ToolSourceAuthUnion] interface which you can cast to the
// specific types for more type safety.
//
-// Possible runtime types of the union are [ToolSourceAuthNoToolSourceAuth],
-// [ToolSourceAuthAPIKeyToolSourceAuth],
-// [ToolSourceAuthOAuthExchangeToolSourceAuth],
-// [ToolSourceAuthOAuthConnectionToolSourceAuth].
+// Possible runtime types of the union are [NoToolSourceAuth],
+// [APIKeyToolSourceAuth], [OAuthExchangeToolSourceAuth],
+// [OAuthConnectionToolSourceAuth].
func (r ToolSourceAuth) AsUnion() ToolSourceAuthUnion {
return r.union
}
@@ -1195,10 +1419,8 @@ func (r ToolSourceAuth) AsUnion() ToolSourceAuthUnion {
// Tool source authentication configuration. The `kind` field selects one of
// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
//
-// Union satisfied by [ToolSourceAuthNoToolSourceAuth],
-// [ToolSourceAuthAPIKeyToolSourceAuth],
-// [ToolSourceAuthOAuthExchangeToolSourceAuth] or
-// [ToolSourceAuthOAuthConnectionToolSourceAuth].
+// Union satisfied by [NoToolSourceAuth], [APIKeyToolSourceAuth],
+// [OAuthExchangeToolSourceAuth] or [OAuthConnectionToolSourceAuth].
type ToolSourceAuthUnion interface {
implementsToolSourceAuth()
}
@@ -1209,197 +1431,27 @@ func init() {
"kind",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ToolSourceAuthNoToolSourceAuth{}),
+ Type: reflect.TypeOf(NoToolSourceAuth{}),
DiscriminatorValue: "none",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ToolSourceAuthAPIKeyToolSourceAuth{}),
+ Type: reflect.TypeOf(APIKeyToolSourceAuth{}),
DiscriminatorValue: "api_key",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ToolSourceAuthOAuthExchangeToolSourceAuth{}),
+ Type: reflect.TypeOf(OAuthExchangeToolSourceAuth{}),
DiscriminatorValue: "oauth_exchange",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ToolSourceAuthOAuthConnectionToolSourceAuth{}),
+ Type: reflect.TypeOf(OAuthConnectionToolSourceAuth{}),
DiscriminatorValue: "oauth_connection",
},
)
}
-type ToolSourceAuthNoToolSourceAuth struct {
- Kind ToolSourceAuthNoToolSourceAuthKind `json:"kind" api:"required"`
- JSON toolSourceAuthNoToolSourceAuthJSON `json:"-"`
-}
-
-// toolSourceAuthNoToolSourceAuthJSON contains the JSON metadata for the struct
-// [ToolSourceAuthNoToolSourceAuth]
-type toolSourceAuthNoToolSourceAuthJSON struct {
- Kind apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ToolSourceAuthNoToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r toolSourceAuthNoToolSourceAuthJSON) RawJSON() string {
- return r.raw
-}
-
-func (r ToolSourceAuthNoToolSourceAuth) implementsToolSourceAuth() {}
-
-type ToolSourceAuthNoToolSourceAuthKind string
-
-const (
- ToolSourceAuthNoToolSourceAuthKindNone ToolSourceAuthNoToolSourceAuthKind = "none"
-)
-
-func (r ToolSourceAuthNoToolSourceAuthKind) IsKnown() bool {
- switch r {
- case ToolSourceAuthNoToolSourceAuthKindNone:
- return true
- }
- return false
-}
-
-type ToolSourceAuthAPIKeyToolSourceAuth struct {
- ConnectionID string `json:"connectionId" api:"required"`
- // Where an API key or OAuth access token should be injected into outgoing
- // tool-source requests.
- Inject AuthInjection `json:"inject" api:"required"`
- Kind ToolSourceAuthAPIKeyToolSourceAuthKind `json:"kind" api:"required"`
- JSON toolSourceAuthAPIKeyToolSourceAuthJSON `json:"-"`
-}
-
-// toolSourceAuthAPIKeyToolSourceAuthJSON contains the JSON metadata for the struct
-// [ToolSourceAuthAPIKeyToolSourceAuth]
-type toolSourceAuthAPIKeyToolSourceAuthJSON struct {
- ConnectionID apijson.Field
- Inject apijson.Field
- Kind apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ToolSourceAuthAPIKeyToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r toolSourceAuthAPIKeyToolSourceAuthJSON) RawJSON() string {
- return r.raw
-}
-
-func (r ToolSourceAuthAPIKeyToolSourceAuth) implementsToolSourceAuth() {}
-
-type ToolSourceAuthAPIKeyToolSourceAuthKind string
-
-const (
- ToolSourceAuthAPIKeyToolSourceAuthKindAPIKey ToolSourceAuthAPIKeyToolSourceAuthKind = "api_key"
-)
-
-func (r ToolSourceAuthAPIKeyToolSourceAuthKind) IsKnown() bool {
- switch r {
- case ToolSourceAuthAPIKeyToolSourceAuthKindAPIKey:
- return true
- }
- return false
-}
-
-type ToolSourceAuthOAuthExchangeToolSourceAuth struct {
- // Source-owned OAuth exchange configuration. Public schemas use connection IDs for
- // stored client secrets and assertions.
- Exchange OAuthExchangeConfig `json:"exchange" api:"required"`
- // Where an API key or OAuth access token should be injected into outgoing
- // tool-source requests.
- Inject AuthInjection `json:"inject" api:"required"`
- Kind ToolSourceAuthOAuthExchangeToolSourceAuthKind `json:"kind" api:"required"`
- JSON toolSourceAuthOAuthExchangeToolSourceAuthJSON `json:"-"`
-}
-
-// toolSourceAuthOAuthExchangeToolSourceAuthJSON contains the JSON metadata for the
-// struct [ToolSourceAuthOAuthExchangeToolSourceAuth]
-type toolSourceAuthOAuthExchangeToolSourceAuthJSON struct {
- Exchange apijson.Field
- Inject apijson.Field
- Kind apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ToolSourceAuthOAuthExchangeToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r toolSourceAuthOAuthExchangeToolSourceAuthJSON) RawJSON() string {
- return r.raw
-}
-
-func (r ToolSourceAuthOAuthExchangeToolSourceAuth) implementsToolSourceAuth() {}
-
-type ToolSourceAuthOAuthExchangeToolSourceAuthKind string
-
-const (
- ToolSourceAuthOAuthExchangeToolSourceAuthKindOAuthExchange ToolSourceAuthOAuthExchangeToolSourceAuthKind = "oauth_exchange"
-)
-
-func (r ToolSourceAuthOAuthExchangeToolSourceAuthKind) IsKnown() bool {
- switch r {
- case ToolSourceAuthOAuthExchangeToolSourceAuthKindOAuthExchange:
- return true
- }
- return false
-}
-
-type ToolSourceAuthOAuthConnectionToolSourceAuth struct {
- Kind ToolSourceAuthOAuthConnectionToolSourceAuthKind `json:"kind" api:"required"`
- Provider string `json:"provider" api:"required"`
- // Where an API key or OAuth access token should be injected into outgoing
- // tool-source requests.
- Inject AuthInjection `json:"inject"`
- RequiredScopes []string `json:"requiredScopes"`
- JSON toolSourceAuthOAuthConnectionToolSourceAuthJSON `json:"-"`
-}
-
-// toolSourceAuthOAuthConnectionToolSourceAuthJSON contains the JSON metadata for
-// the struct [ToolSourceAuthOAuthConnectionToolSourceAuth]
-type toolSourceAuthOAuthConnectionToolSourceAuthJSON struct {
- Kind apijson.Field
- Provider apijson.Field
- Inject apijson.Field
- RequiredScopes apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *ToolSourceAuthOAuthConnectionToolSourceAuth) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r toolSourceAuthOAuthConnectionToolSourceAuthJSON) RawJSON() string {
- return r.raw
-}
-
-func (r ToolSourceAuthOAuthConnectionToolSourceAuth) implementsToolSourceAuth() {}
-
-type ToolSourceAuthOAuthConnectionToolSourceAuthKind string
-
-const (
- ToolSourceAuthOAuthConnectionToolSourceAuthKindOAuthConnection ToolSourceAuthOAuthConnectionToolSourceAuthKind = "oauth_connection"
-)
-
-func (r ToolSourceAuthOAuthConnectionToolSourceAuthKind) IsKnown() bool {
- switch r {
- case ToolSourceAuthOAuthConnectionToolSourceAuthKindOAuthConnection:
- return true
- }
- return false
-}
-
type ToolSourceAuthKind string
const (
@@ -1441,83 +1493,27 @@ func (r ToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
// Tool source authentication configuration. The `kind` field selects one of
// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
//
-// Satisfied by [ToolSourceAuthNoToolSourceAuthParam],
-// [ToolSourceAuthAPIKeyToolSourceAuthParam],
-// [ToolSourceAuthOAuthExchangeToolSourceAuthParam],
-// [ToolSourceAuthOAuthConnectionToolSourceAuthParam], [ToolSourceAuthParam].
+// Satisfied by [NoToolSourceAuthParam], [APIKeyToolSourceAuthParam],
+// [OAuthExchangeToolSourceAuthParam], [OAuthConnectionToolSourceAuthParam],
+// [ToolSourceAuthParam].
type ToolSourceAuthUnionParam interface {
implementsToolSourceAuthUnionParam()
}
-type ToolSourceAuthNoToolSourceAuthParam struct {
- Kind param.Field[ToolSourceAuthNoToolSourceAuthKind] `json:"kind" api:"required"`
-}
-
-func (r ToolSourceAuthNoToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceAuthNoToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
-
-type ToolSourceAuthAPIKeyToolSourceAuthParam struct {
- ConnectionID param.Field[string] `json:"connectionId" api:"required"`
- // Where an API key or OAuth access token should be injected into outgoing
- // tool-source requests.
- Inject param.Field[AuthInjectionUnionParam] `json:"inject" api:"required"`
- Kind param.Field[ToolSourceAuthAPIKeyToolSourceAuthKind] `json:"kind" api:"required"`
-}
-
-func (r ToolSourceAuthAPIKeyToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceAuthAPIKeyToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
-
-type ToolSourceAuthOAuthExchangeToolSourceAuthParam struct {
- // Source-owned OAuth exchange configuration. Public schemas use connection IDs for
- // stored client secrets and assertions.
- Exchange param.Field[OAuthExchangeConfigUnionParam] `json:"exchange" api:"required"`
- // Where an API key or OAuth access token should be injected into outgoing
- // tool-source requests.
- Inject param.Field[AuthInjectionUnionParam] `json:"inject" api:"required"`
- Kind param.Field[ToolSourceAuthOAuthExchangeToolSourceAuthKind] `json:"kind" api:"required"`
-}
-
-func (r ToolSourceAuthOAuthExchangeToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceAuthOAuthExchangeToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
-
-type ToolSourceAuthOAuthConnectionToolSourceAuthParam struct {
- Kind param.Field[ToolSourceAuthOAuthConnectionToolSourceAuthKind] `json:"kind" api:"required"`
- Provider param.Field[string] `json:"provider" api:"required"`
- // Where an API key or OAuth access token should be injected into outgoing
- // tool-source requests.
- Inject param.Field[AuthInjectionUnionParam] `json:"inject"`
- RequiredScopes param.Field[[]string] `json:"requiredScopes"`
-}
-
-func (r ToolSourceAuthOAuthConnectionToolSourceAuthParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
-}
-
-func (r ToolSourceAuthOAuthConnectionToolSourceAuthParam) implementsToolSourceAuthUnionParam() {}
-
type ToolNewParams struct {
- Tool ToolNewParamsToolUnion `json:"tool" api:"required"`
+ Body ToolNewParamsBodyUnion `json:"body" api:"required"`
}
func (r ToolNewParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r.Tool)
+ return apijson.MarshalRoot(r.Body)
}
-type ToolNewParamsTool struct {
+type ToolNewParamsBody struct {
// Tool source authentication configuration. The `kind` field selects one of
// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[ToolNewParamsToolType] `json:"type" api:"required"`
+ Type param.Field[ToolNewParamsBodyType] `json:"type" api:"required"`
Approval param.Field[ToolApprovalMode] `json:"approval"`
Enabled param.Field[bool] `json:"enabled"`
Execution param.Field[interface{}] `json:"execution"`
@@ -1525,25 +1521,25 @@ type ToolNewParamsTool struct {
URL param.Field[string] `json:"url"`
}
-func (r ToolNewParamsTool) MarshalJSON() (data []byte, err error) {
+func (r ToolNewParamsBody) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r ToolNewParamsTool) implementsToolNewParamsToolUnion() {}
+func (r ToolNewParamsBody) implementsToolNewParamsBodyUnion() {}
-// Satisfied by [ToolNewParamsToolCreateHTTPToolSourceRequest],
-// [ToolNewParamsToolCreateMcpToolSourceRequest], [ToolNewParamsTool].
-type ToolNewParamsToolUnion interface {
- implementsToolNewParamsToolUnion()
+// Satisfied by [ToolNewParamsBodyCreateHTTPToolSourceRequest],
+// [ToolNewParamsBodyCreateMcpToolSourceRequest], [ToolNewParamsBody].
+type ToolNewParamsBodyUnion interface {
+ implementsToolNewParamsBodyUnion()
}
-type ToolNewParamsToolCreateHTTPToolSourceRequest struct {
+type ToolNewParamsBodyCreateHTTPToolSourceRequest struct {
// Tool source authentication configuration. The `kind` field selects one of
// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
Namespace param.Field[string] `json:"namespace" api:"required"`
Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
- Type param.Field[ToolNewParamsToolCreateHTTPToolSourceRequestType] `json:"type" api:"required"`
+ Type param.Field[ToolNewParamsBodyCreateHTTPToolSourceRequestType] `json:"type" api:"required"`
Approval param.Field[ToolApprovalMode] `json:"approval"`
Enabled param.Field[bool] `json:"enabled"`
// HTTP tool execution retry and timeout policy.
@@ -1551,32 +1547,32 @@ type ToolNewParamsToolCreateHTTPToolSourceRequest struct {
ExtraFields map[string]interface{} `json:"-,extras"`
}
-func (r ToolNewParamsToolCreateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
+func (r ToolNewParamsBodyCreateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r ToolNewParamsToolCreateHTTPToolSourceRequest) implementsToolNewParamsToolUnion() {}
+func (r ToolNewParamsBodyCreateHTTPToolSourceRequest) implementsToolNewParamsBodyUnion() {}
-type ToolNewParamsToolCreateHTTPToolSourceRequestType string
+type ToolNewParamsBodyCreateHTTPToolSourceRequestType string
const (
- ToolNewParamsToolCreateHTTPToolSourceRequestTypeHTTP ToolNewParamsToolCreateHTTPToolSourceRequestType = "http"
+ ToolNewParamsBodyCreateHTTPToolSourceRequestTypeHTTP ToolNewParamsBodyCreateHTTPToolSourceRequestType = "http"
)
-func (r ToolNewParamsToolCreateHTTPToolSourceRequestType) IsKnown() bool {
+func (r ToolNewParamsBodyCreateHTTPToolSourceRequestType) IsKnown() bool {
switch r {
- case ToolNewParamsToolCreateHTTPToolSourceRequestTypeHTTP:
+ case ToolNewParamsBodyCreateHTTPToolSourceRequestTypeHTTP:
return true
}
return false
}
-type ToolNewParamsToolCreateMcpToolSourceRequest struct {
+type ToolNewParamsBodyCreateMcpToolSourceRequest struct {
// Tool source authentication configuration. The `kind` field selects one of
// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[ToolNewParamsToolCreateMcpToolSourceRequestType] `json:"type" api:"required"`
+ Type param.Field[ToolNewParamsBodyCreateMcpToolSourceRequestType] `json:"type" api:"required"`
URL param.Field[string] `json:"url" api:"required"`
Approval param.Field[ToolApprovalMode] `json:"approval"`
Enabled param.Field[bool] `json:"enabled"`
@@ -1585,55 +1581,55 @@ type ToolNewParamsToolCreateMcpToolSourceRequest struct {
ExtraFields map[string]interface{} `json:"-,extras"`
}
-func (r ToolNewParamsToolCreateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
+func (r ToolNewParamsBodyCreateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r ToolNewParamsToolCreateMcpToolSourceRequest) implementsToolNewParamsToolUnion() {}
+func (r ToolNewParamsBodyCreateMcpToolSourceRequest) implementsToolNewParamsBodyUnion() {}
-type ToolNewParamsToolCreateMcpToolSourceRequestType string
+type ToolNewParamsBodyCreateMcpToolSourceRequestType string
const (
- ToolNewParamsToolCreateMcpToolSourceRequestTypeMcp ToolNewParamsToolCreateMcpToolSourceRequestType = "mcp"
+ ToolNewParamsBodyCreateMcpToolSourceRequestTypeMcp ToolNewParamsBodyCreateMcpToolSourceRequestType = "mcp"
)
-func (r ToolNewParamsToolCreateMcpToolSourceRequestType) IsKnown() bool {
+func (r ToolNewParamsBodyCreateMcpToolSourceRequestType) IsKnown() bool {
switch r {
- case ToolNewParamsToolCreateMcpToolSourceRequestTypeMcp:
+ case ToolNewParamsBodyCreateMcpToolSourceRequestTypeMcp:
return true
}
return false
}
-type ToolNewParamsToolType string
+type ToolNewParamsBodyType string
const (
- ToolNewParamsToolTypeHTTP ToolNewParamsToolType = "http"
- ToolNewParamsToolTypeMcp ToolNewParamsToolType = "mcp"
+ ToolNewParamsBodyTypeHTTP ToolNewParamsBodyType = "http"
+ ToolNewParamsBodyTypeMcp ToolNewParamsBodyType = "mcp"
)
-func (r ToolNewParamsToolType) IsKnown() bool {
+func (r ToolNewParamsBodyType) IsKnown() bool {
switch r {
- case ToolNewParamsToolTypeHTTP, ToolNewParamsToolTypeMcp:
+ case ToolNewParamsBodyTypeHTTP, ToolNewParamsBodyTypeMcp:
return true
}
return false
}
type ToolUpdateParams struct {
- Tool ToolUpdateParamsToolUnion `json:"tool" api:"required"`
+ Body ToolUpdateParamsBodyUnion `json:"body" api:"required"`
}
func (r ToolUpdateParams) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r.Tool)
+ return apijson.MarshalRoot(r.Body)
}
-type ToolUpdateParamsTool struct {
+type ToolUpdateParamsBody struct {
// Tool source authentication configuration. The `kind` field selects one of
// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[ToolUpdateParamsToolType] `json:"type" api:"required"`
+ Type param.Field[ToolUpdateParamsBodyType] `json:"type" api:"required"`
Approval param.Field[ToolApprovalMode] `json:"approval"`
Enabled param.Field[bool] `json:"enabled"`
Execution param.Field[interface{}] `json:"execution"`
@@ -1641,25 +1637,25 @@ type ToolUpdateParamsTool struct {
URL param.Field[string] `json:"url"`
}
-func (r ToolUpdateParamsTool) MarshalJSON() (data []byte, err error) {
+func (r ToolUpdateParamsBody) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r ToolUpdateParamsTool) implementsToolUpdateParamsToolUnion() {}
+func (r ToolUpdateParamsBody) implementsToolUpdateParamsBodyUnion() {}
-// Satisfied by [ToolUpdateParamsToolUpdateHTTPToolSourceRequest],
-// [ToolUpdateParamsToolUpdateMcpToolSourceRequest], [ToolUpdateParamsTool].
-type ToolUpdateParamsToolUnion interface {
- implementsToolUpdateParamsToolUnion()
+// Satisfied by [ToolUpdateParamsBodyUpdateHTTPToolSourceRequest],
+// [ToolUpdateParamsBodyUpdateMcpToolSourceRequest], [ToolUpdateParamsBody].
+type ToolUpdateParamsBodyUnion interface {
+ implementsToolUpdateParamsBodyUnion()
}
-type ToolUpdateParamsToolUpdateHTTPToolSourceRequest struct {
+type ToolUpdateParamsBodyUpdateHTTPToolSourceRequest struct {
// Tool source authentication configuration. The `kind` field selects one of
// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
Namespace param.Field[string] `json:"namespace" api:"required"`
Tools param.Field[[]HTTPToolDefinitionParam] `json:"tools" api:"required"`
- Type param.Field[ToolUpdateParamsToolUpdateHTTPToolSourceRequestType] `json:"type" api:"required"`
+ Type param.Field[ToolUpdateParamsBodyUpdateHTTPToolSourceRequestType] `json:"type" api:"required"`
Approval param.Field[ToolApprovalMode] `json:"approval"`
Enabled param.Field[bool] `json:"enabled"`
// HTTP tool execution retry and timeout policy.
@@ -1667,32 +1663,32 @@ type ToolUpdateParamsToolUpdateHTTPToolSourceRequest struct {
ExtraFields map[string]interface{} `json:"-,extras"`
}
-func (r ToolUpdateParamsToolUpdateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
+func (r ToolUpdateParamsBodyUpdateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r ToolUpdateParamsToolUpdateHTTPToolSourceRequest) implementsToolUpdateParamsToolUnion() {}
+func (r ToolUpdateParamsBodyUpdateHTTPToolSourceRequest) implementsToolUpdateParamsBodyUnion() {}
-type ToolUpdateParamsToolUpdateHTTPToolSourceRequestType string
+type ToolUpdateParamsBodyUpdateHTTPToolSourceRequestType string
const (
- ToolUpdateParamsToolUpdateHTTPToolSourceRequestTypeHTTP ToolUpdateParamsToolUpdateHTTPToolSourceRequestType = "http"
+ ToolUpdateParamsBodyUpdateHTTPToolSourceRequestTypeHTTP ToolUpdateParamsBodyUpdateHTTPToolSourceRequestType = "http"
)
-func (r ToolUpdateParamsToolUpdateHTTPToolSourceRequestType) IsKnown() bool {
+func (r ToolUpdateParamsBodyUpdateHTTPToolSourceRequestType) IsKnown() bool {
switch r {
- case ToolUpdateParamsToolUpdateHTTPToolSourceRequestTypeHTTP:
+ case ToolUpdateParamsBodyUpdateHTTPToolSourceRequestTypeHTTP:
return true
}
return false
}
-type ToolUpdateParamsToolUpdateMcpToolSourceRequest struct {
+type ToolUpdateParamsBodyUpdateMcpToolSourceRequest struct {
// Tool source authentication configuration. The `kind` field selects one of
// `none`, `api_key`, `oauth_exchange`, or `oauth_connection`.
Auth param.Field[ToolSourceAuthUnionParam] `json:"auth" api:"required"`
Namespace param.Field[string] `json:"namespace" api:"required"`
- Type param.Field[ToolUpdateParamsToolUpdateMcpToolSourceRequestType] `json:"type" api:"required"`
+ Type param.Field[ToolUpdateParamsBodyUpdateMcpToolSourceRequestType] `json:"type" api:"required"`
URL param.Field[string] `json:"url" api:"required"`
Approval param.Field[ToolApprovalMode] `json:"approval"`
Enabled param.Field[bool] `json:"enabled"`
@@ -1701,36 +1697,36 @@ type ToolUpdateParamsToolUpdateMcpToolSourceRequest struct {
ExtraFields map[string]interface{} `json:"-,extras"`
}
-func (r ToolUpdateParamsToolUpdateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
+func (r ToolUpdateParamsBodyUpdateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r ToolUpdateParamsToolUpdateMcpToolSourceRequest) implementsToolUpdateParamsToolUnion() {}
+func (r ToolUpdateParamsBodyUpdateMcpToolSourceRequest) implementsToolUpdateParamsBodyUnion() {}
-type ToolUpdateParamsToolUpdateMcpToolSourceRequestType string
+type ToolUpdateParamsBodyUpdateMcpToolSourceRequestType string
const (
- ToolUpdateParamsToolUpdateMcpToolSourceRequestTypeMcp ToolUpdateParamsToolUpdateMcpToolSourceRequestType = "mcp"
+ ToolUpdateParamsBodyUpdateMcpToolSourceRequestTypeMcp ToolUpdateParamsBodyUpdateMcpToolSourceRequestType = "mcp"
)
-func (r ToolUpdateParamsToolUpdateMcpToolSourceRequestType) IsKnown() bool {
+func (r ToolUpdateParamsBodyUpdateMcpToolSourceRequestType) IsKnown() bool {
switch r {
- case ToolUpdateParamsToolUpdateMcpToolSourceRequestTypeMcp:
+ case ToolUpdateParamsBodyUpdateMcpToolSourceRequestTypeMcp:
return true
}
return false
}
-type ToolUpdateParamsToolType string
+type ToolUpdateParamsBodyType string
const (
- ToolUpdateParamsToolTypeHTTP ToolUpdateParamsToolType = "http"
- ToolUpdateParamsToolTypeMcp ToolUpdateParamsToolType = "mcp"
+ ToolUpdateParamsBodyTypeHTTP ToolUpdateParamsBodyType = "http"
+ ToolUpdateParamsBodyTypeMcp ToolUpdateParamsBodyType = "mcp"
)
-func (r ToolUpdateParamsToolType) IsKnown() bool {
+func (r ToolUpdateParamsBodyType) IsKnown() bool {
switch r {
- case ToolUpdateParamsToolTypeHTTP, ToolUpdateParamsToolTypeMcp:
+ case ToolUpdateParamsBodyTypeHTTP, ToolUpdateParamsBodyTypeMcp:
return true
}
return false
diff --git a/tool_test.go b/tool_test.go
index 001b5fe..30be93e 100644
--- a/tool_test.go
+++ b/tool_test.go
@@ -29,9 +29,9 @@ func TestToolNewWithOptionalParams(t *testing.T) {
context.TODO(),
"fleet_abc123",
cercago.ToolNewParams{
- Tool: cercago.ToolNewParamsToolCreateHTTPToolSourceRequest{
- Auth: cercago.F[cercago.ToolSourceAuthUnionParam](cercago.ToolSourceAuthNoToolSourceAuthParam{
- Kind: cercago.F(cercago.ToolSourceAuthNoToolSourceAuthKindNone),
+ Body: cercago.ToolNewParamsBodyCreateHTTPToolSourceRequest{
+ Auth: cercago.F[cercago.ToolSourceAuthUnionParam](cercago.NoToolSourceAuthParam{
+ Kind: cercago.F(cercago.NoToolSourceAuthKindNone),
}),
Namespace: cercago.F("docs"),
Tools: cercago.F([]cercago.HTTPToolDefinitionParam{{
@@ -65,7 +65,7 @@ func TestToolNewWithOptionalParams(t *testing.T) {
Mode: cercago.F(cercago.ResponseNormalizationHintModeAuto),
}),
}}),
- Type: cercago.F(cercago.ToolNewParamsToolCreateHTTPToolSourceRequestTypeHTTP),
+ Type: cercago.F(cercago.ToolNewParamsBodyCreateHTTPToolSourceRequestTypeHTTP),
Approval: cercago.F(cercago.ToolApprovalModeAlways),
Enabled: cercago.F(true),
Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
@@ -129,9 +129,9 @@ func TestToolUpdateWithOptionalParams(t *testing.T) {
"fleet_abc123",
"toolsrc_abc123",
cercago.ToolUpdateParams{
- Tool: cercago.ToolUpdateParamsToolUpdateHTTPToolSourceRequest{
- Auth: cercago.F[cercago.ToolSourceAuthUnionParam](cercago.ToolSourceAuthNoToolSourceAuthParam{
- Kind: cercago.F(cercago.ToolSourceAuthNoToolSourceAuthKindNone),
+ Body: cercago.ToolUpdateParamsBodyUpdateHTTPToolSourceRequest{
+ Auth: cercago.F[cercago.ToolSourceAuthUnionParam](cercago.NoToolSourceAuthParam{
+ Kind: cercago.F(cercago.NoToolSourceAuthKindNone),
}),
Namespace: cercago.F("docs"),
Tools: cercago.F([]cercago.HTTPToolDefinitionParam{{
@@ -165,7 +165,7 @@ func TestToolUpdateWithOptionalParams(t *testing.T) {
Mode: cercago.F(cercago.ResponseNormalizationHintModeAuto),
}),
}}),
- Type: cercago.F(cercago.ToolUpdateParamsToolUpdateHTTPToolSourceRequestTypeHTTP),
+ Type: cercago.F(cercago.ToolUpdateParamsBodyUpdateHTTPToolSourceRequestTypeHTTP),
Approval: cercago.F(cercago.ToolApprovalModeAlways),
Enabled: cercago.F(true),
Execution: cercago.F(cercago.HTTPToolExecutionPolicyParam{
From 470ebbe41fbf0e8260b4042502bbbc758942a5d6 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Fri, 1 May 2026 23:58:22 +0000
Subject: [PATCH 29/29] release: 0.1.0
---
.release-please-manifest.json | 2 +-
CHANGELOG.md | 25 +++++++++++++++++++++++++
README.md | 2 +-
internal/version.go | 2 +-
4 files changed, 28 insertions(+), 3 deletions(-)
create mode 100644 CHANGELOG.md
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 1332969..3d2ac0b 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.0.1"
+ ".": "0.1.0"
}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..9743757
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,25 @@
+# Changelog
+
+## 0.1.0 (2026-05-01)
+
+Full Changelog: [v0.0.1...v0.1.0](https://github.com/matrices/cerca-go/compare/v0.0.1...v0.1.0)
+
+### Features
+
+* **api:** api update ([59da953](https://github.com/matrices/cerca-go/commit/59da953ed2c87a54dfa22a339651d6b1cf48ddce))
+* **api:** api update ([b87d3ca](https://github.com/matrices/cerca-go/commit/b87d3caf820dceb55385e68abc20ed9a98f3f59a))
+* **api:** api update ([1993ace](https://github.com/matrices/cerca-go/commit/1993ace6337df84d6f5f898493a3f63af7ad14e7))
+* **api:** api update ([d7e1bc0](https://github.com/matrices/cerca-go/commit/d7e1bc066e9d6e1168070a1bb0b94159d161a98c))
+* **api:** manual updates ([8670a4e](https://github.com/matrices/cerca-go/commit/8670a4e255e029af5600c5355ecc1054c43eceb0))
+* **api:** manual updates ([2763780](https://github.com/matrices/cerca-go/commit/2763780292758cbac65255da7a8c83d0cb1800a7))
+* **api:** manual updates ([5400c58](https://github.com/matrices/cerca-go/commit/5400c5818fb359dd56b8ddd3c31454c55873aefa))
+* **go:** add default http client with timeout ([5264d8d](https://github.com/matrices/cerca-go/commit/5264d8d2efdbf5b4b5d5ccc16b0442feaa1827b2))
+* support setting headers via env ([5c6579f](https://github.com/matrices/cerca-go/commit/5c6579f082703dbd457d333312c3d11eeb3ded86))
+
+
+### Chores
+
+* avoid embedding reflect.Type for dead code elimination ([3a4ca71](https://github.com/matrices/cerca-go/commit/3a4ca71ce279af304fce557e47a883a0a80dd285))
+* configure new SDK language ([f3c82b6](https://github.com/matrices/cerca-go/commit/f3c82b6f072168405c3aa4b2a4e03fc283f44c26))
+* **internal:** more robust bootstrap script ([5e7983b](https://github.com/matrices/cerca-go/commit/5e7983b03881403b643d1c2ff43f12f900873deb))
+* **tests:** bump steady to v0.22.1 ([3d1fcf8](https://github.com/matrices/cerca-go/commit/3d1fcf893fdfeda758337ae72803c56024f3d749))
diff --git a/README.md b/README.md
index b576cd2..c7bf64a 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ Or to pin the version:
```sh
-go get -u 'github.com/matrices/cerca-go@v0.0.1'
+go get -u 'github.com/matrices/cerca-go@v0.1.0'
```
diff --git a/internal/version.go b/internal/version.go
index ebdd35f..02eac73 100644
--- a/internal/version.go
+++ b/internal/version.go
@@ -2,4 +2,4 @@
package internal
-const PackageVersion = "0.0.1" // x-release-please-version
+const PackageVersion = "0.1.0" // x-release-please-version