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/.stats.yml b/.stats.yml
index f3c3396..57e5ba5 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
+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/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 883efda..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'
```
@@ -52,11 +52,11 @@ 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{
- UserMessage: cercago.F("What's on my calendar today?"),
+ "agent_abc123",
+ cercago.ThreadNewParams{
+ Message: cercago.F("What's on my calendar today?"),
},
)
if err != nil {
@@ -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..7200dbe
--- /dev/null
+++ b/agent.go
@@ -0,0 +1,998 @@
+// 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
+}
+
+// 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"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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"`
+ // 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]
+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"`
+ // 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) {
+ 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
+}
+
+// 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"`
+ // 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
+// [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(),
+ "kind",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ExecutionPrincipalUserExecutionPrincipal{}),
+ DiscriminatorValue: "user",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ExecutionPrincipalAPIKeyExecutionPrincipal{}),
+ DiscriminatorValue: "apiKey",
+ },
+ )
+}
+
+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 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 [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"`
+ // 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]
+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:"-"`
+}
+
+// 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
+}
+
+// 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"`
+ // 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) {
+ 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..717242a
--- /dev/null
+++ b/agent_test.go
@@ -0,0 +1,237 @@
+// 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{
+ 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",
+ }),
+ UserID: cercago.F("userId"),
+ })
+ 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 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 {
+ 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..0b3eac1 100644
--- a/aliases.go
+++ b/aliases.go
@@ -4,6 +4,144 @@ 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 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._. 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._. 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 dfc0d3c..d429f6d 100644
--- a/api.md
+++ b/api.md
@@ -1,14 +1,26 @@
+# Shared Params Types
+
+- shared.ApprovalMode
+- shared.ToolName
+- shared.ToolSpecParam
+
+# Shared Response Types
+
+- shared.ApprovalMode
+- 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
@@ -20,59 +32,86 @@ 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.CredentialListResponse
-- cercago.CredentialDeleteResponse
+- cercago.ToolConnectionMetadata
+- cercago.ConnectionDeleteResponse
+- cercago.ConnectionDetachResponse
+- cercago.ConnectionListForAgentResponse
Methods:
-- client.Credentials.List(ctx context.Context, scope string, query cercago.CredentialListParams) (\*cercago.CredentialListResponse, 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)
-# Environments
+# Fleets
Response Types:
-- cercago.Environment
+- cercago.Fleet
-## ToolSources
+# Tools
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.ToolSourceAuthParam
+- cercago.ToolSourceAuthUnionParam
Response Types:
+- cercago.APIKeyToolSourceAuth
+- cercago.AuthInjection
+- cercago.HTTPEndpoint
- cercago.HTTPToolDefinition
- cercago.HTTPToolExecutionPolicy
- cercago.HTTPToolSource
- cercago.McpToolExecutionPolicy
- cercago.McpToolSource
+- cercago.NoToolSourceAuth
+- cercago.OAuthConnectionToolSourceAuth
+- cercago.OAuthExchangeConfig
+- cercago.OAuthExchangeToolSourceAuth
+- cercago.ResponseNormalizationHint
- cercago.ToolApprovalMode
- cercago.ToolSource
- cercago.ToolSourceAuth
-- cercago.EnvironmentToolSourceListResponse
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.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
+# Webhooks
Params Types:
@@ -83,295 +122,175 @@ 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
+- cercago.ThreadStreamEvent
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.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)
-# 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.DiscoveredTool
+- cercago.EffectiveConfiguration
- cercago.ExecutionPrincipal
-- cercago.RuntimeToolApprovalOverrideMode
-- cercago.CellListResponse
-- cercago.CellDeleteResponse
-
-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.Cells.Metadata.Update(ctx context.Context, cellID string, body cercago.CellMetadataUpdateParams) (\*cercago.Cell, error)
-
-## Tools
-
-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
+- cercago.Metadata
+- cercago.SourceWarning
+- cercago.Tool
+- cercago.ToolDescriptor
+- cercago.AgentDeleteResponse
+- cercago.AgentListToolsResponse
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)
+- 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.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)
-## Threads
+# Threads
Params Types:
-- cercago.ThreadStatus
+- cercago.Status
Response Types:
+- cercago.CompiledContext
- cercago.ContentBlock
-- cercago.PendingSubThread
+- cercago.Message
+- cercago.Status
- cercago.SteerResult
+- cercago.SubThreadSummary
- 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
+- 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)
-Methods:
-
-- client.Cells.Threads.Approvals.Resolve(ctx context.Context, cellID string, threadID string, approvalID string, body cercago.CellThreadApprovalResolveParams) (\*cercago.ApprovalRequest, error)
-
-### ApprovalGrants
-
-Response Types:
-
-- cercago.CellThreadApprovalGrantDeleteResponse
-
-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)
-
-### Logs
+# Context
Response Types:
-- cercago.ThreadLog
-- cercago.CellThreadLogListResponse
+- cercago.Entry
+- cercago.EntrySummary
+- cercago.SearchResult
+- cercago.ContextDeleteResponse
Methods:
-- client.Cells.Threads.Logs.List(ctx context.Context, cellID string, threadID string, query cercago.CellThreadLogListParams) (\*cercago.CellThreadLogListResponse, 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)
-### Events
+# Schedules
Response Types:
-- cercago.CellThreadEventListResponse
-- cercago.CellThreadEventSubscribeResponse
+- cercago.Schedule
+- 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.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:
- cercago.ApprovalRequest
-- cercago.CellApprovalListResponse
Methods:
-- client.Cells.Approvals.List(ctx context.Context, cellID string, query cercago.CellApprovalListParams) (\*cercago.CellApprovalListResponse, 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
+# ApprovalGrants
Response Types:
- cercago.ApprovalGrant
-- cercago.CellApprovalGrantListResponse
-- cercago.CellApprovalGrantDeleteResponse
-
-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)
-
-## Logs
-
-Response Types:
-
-- cercago.CellLogListResponse
-
-Methods:
-
-- client.Cells.Logs.List(ctx context.Context, cellID string, query cercago.CellLogListParams) (\*cercago.CellLogListResponse, error)
-
-## Sandbox
-
-Response Types:
-
-- cercago.SandboxExecResult
-- cercago.SandboxReadResponse
-- cercago.CellSandboxWriteResponse
+- cercago.ApprovalGrantDeleteResponse
+- cercago.ApprovalGrantDeleteForThreadResponse
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.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)
-## Events
+# Sandbox
Response Types:
-- cercago.CellEventListResponse
-- cercago.CellEventSubscribeResponse
+- cercago.ExecResult
+- cercago.ReadResponse
+- cercago.SandboxWriteResponse
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.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)
# Models
diff --git a/approvalgrant.go b/approvalgrant.go
new file mode 100644
index 0000000..2685e71
--- /dev/null
+++ b/approvalgrant.go
@@ -0,0 +1,249 @@
+// 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
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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/credential_test.go b/approvalgrant_test.go
similarity index 62%
rename from credential_test.go
rename to approvalgrant_test.go
index 5f2d503..75662f4 100644
--- a/credential_test.go
+++ b/approvalgrant_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCredentialListWithOptionalParams(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,10 +25,10 @@ func TestCredentialListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Credentials.List(
+ _, err := client.ApprovalGrants.List(
context.TODO(),
- "env:org_abc123:env_abc123",
- cercago.CredentialListParams{
+ "agent_abc123",
+ cercago.ApprovalGrantListParams{
Cursor: cercago.F("cursor_abc123"),
Limit: cercago.F("20"),
},
@@ -42,7 +42,7 @@ func TestCredentialListWithOptionalParams(t *testing.T) {
}
}
-func TestCredentialDelete(t *testing.T) {
+func TestApprovalGrantDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -54,10 +54,10 @@ func TestCredentialDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Credentials.Delete(
+ _, err := client.ApprovalGrants.Delete(
context.TODO(),
- "env:org_abc123:env_abc123",
- "env:org_abc123:env_abc123::conn_abc123",
+ "agent_abc123",
+ "grant_abc123",
)
if err != nil {
var apierr *cercago.Error
@@ -68,7 +68,7 @@ func TestCredentialDelete(t *testing.T) {
}
}
-func TestCredentialNewAPIKeyWithOptionalParams(t *testing.T) {
+func TestApprovalGrantDeleteForThread(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -80,14 +80,37 @@ func TestCredentialNewAPIKeyWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Credentials.NewAPIKey(
+ _, err := client.ApprovalGrants.DeleteForThread(
context.TODO(),
- "env:org_abc123:env_abc123",
- cercago.CredentialNewAPIKeyParams{
- APIKey: cercago.F("sk_live_..."),
- Provider: cercago.F("custom"),
- AccountLabel: cercago.F("primary"),
- },
+ "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/approvalrequest.go b/approvalrequest.go
new file mode 100644
index 0000000..411cafc
--- /dev/null
+++ b/approvalrequest.go
@@ -0,0 +1,213 @@
+// 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"
+)
+
+// 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 [NewApprovalRequestService] method instead.
+type ApprovalRequestService struct {
+ Options []option.RequestOption
+}
+
+// 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 NewApprovalRequestService(opts ...option.RequestOption) (r *ApprovalRequestService) {
+ r = &ApprovalRequestService{}
+ r.Options = opts
+ return
+}
+
+// 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)
+ 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/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
+}
+
+// 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...))
+}
+
+// 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 == "" {
+ 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
+}
+
+type ApprovalRequest struct {
+ 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"`
+ 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 approvalRequestJSON `json:"-"`
+}
+
+// approvalRequestJSON contains the JSON metadata for the struct [ApprovalRequest]
+type approvalRequestJSON 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 *ApprovalRequest) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r approvalRequestJSON) RawJSON() string {
+ return r.raw
+}
+
+type ApprovalRequestStatus string
+
+const (
+ ApprovalRequestStatusPending ApprovalRequestStatus = "pending"
+ ApprovalRequestStatusApproved ApprovalRequestStatus = "approved"
+ ApprovalRequestStatusDenied ApprovalRequestStatus = "denied"
+ ApprovalRequestStatusCancelled ApprovalRequestStatus = "cancelled"
+ ApprovalRequestStatusTimedOut ApprovalRequestStatus = "timed_out"
+)
+
+func (r ApprovalRequestStatus) IsKnown() bool {
+ switch r {
+ case ApprovalRequestStatusPending, ApprovalRequestStatusApproved, ApprovalRequestStatusDenied, ApprovalRequestStatusCancelled, ApprovalRequestStatusTimedOut:
+ return true
+ }
+ return false
+}
+
+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
+ // semantics.
+ Limit param.Field[string] `query:"limit"`
+ // Optional thread id filter.
+ ThreadID param.Field[string] `query:"threadId"`
+}
+
+// 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 ApprovalRequestResolveParams struct {
+ Decision param.Field[ApprovalRequestResolveParamsDecision] `json:"decision" api:"required"`
+ Grant param.Field[ApprovalRequestResolveParamsGrant] `json:"grant"`
+}
+
+func (r ApprovalRequestResolveParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type ApprovalRequestResolveParamsDecision string
+
+const (
+ ApprovalRequestResolveParamsDecisionApprove ApprovalRequestResolveParamsDecision = "approve"
+ ApprovalRequestResolveParamsDecisionDeny ApprovalRequestResolveParamsDecision = "deny"
+ ApprovalRequestResolveParamsDecisionCancel ApprovalRequestResolveParamsDecision = "cancel"
+)
+
+func (r ApprovalRequestResolveParamsDecision) IsKnown() bool {
+ switch r {
+ case ApprovalRequestResolveParamsDecisionApprove, ApprovalRequestResolveParamsDecisionDeny, ApprovalRequestResolveParamsDecisionCancel:
+ return true
+ }
+ return false
+}
+
+type ApprovalRequestResolveParamsGrant string
+
+const (
+ ApprovalRequestResolveParamsGrantThread ApprovalRequestResolveParamsGrant = "thread"
+ ApprovalRequestResolveParamsGrantAgent ApprovalRequestResolveParamsGrant = "agent"
+)
+
+func (r ApprovalRequestResolveParamsGrant) IsKnown() bool {
+ switch r {
+ case ApprovalRequestResolveParamsGrantThread, ApprovalRequestResolveParamsGrantAgent:
+ return true
+ }
+ return false
+}
diff --git a/cellthreadevent_test.go b/approvalrequest_test.go
similarity index 66%
rename from cellthreadevent_test.go
rename to approvalrequest_test.go
index 4aab4fd..167a48a 100644
--- a/cellthreadevent_test.go
+++ b/approvalrequest_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellThreadEventListWithOptionalParams(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,15 +25,13 @@ func TestCellThreadEventListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Threads.Events.List(
+ _, err := client.ApprovalRequests.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.ApprovalRequestListParams{
+ 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 TestApprovalRequestResolveWithOptionalParams(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.ApprovalRequests.Resolve(
context.TODO(),
- "cell_abc123",
+ "agent_abc123",
"thread_abc123",
+ "approval_abc123",
+ cercago.ApprovalRequestResolveParams{
+ Decision: cercago.F(cercago.ApprovalRequestResolveParamsDecisionApprove),
+ Grant: cercago.F(cercago.ApprovalRequestResolveParamsGrantThread),
+ },
)
if err != nil {
var apierr *cercago.Error
diff --git a/auth.go b/auth.go
index 27378f9..208db52 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
@@ -34,6 +35,7 @@ func NewAuthService(opts ...option.RequestOption) (r *AuthService) {
return
}
+// 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"
@@ -41,11 +43,27 @@ 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) {
+// 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)
- 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
+}
+
+// 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...))
}
type AuthContextResponse struct {
@@ -71,32 +89,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 +122,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.go b/cellapproval.go
deleted file mode 100644
index be997e5..0000000
--- a/cellapproval.go
+++ /dev/null
@@ -1,157 +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"
-)
-
-// CellApprovalService 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 {
- Options []option.RequestOption
-}
-
-// NewCellApprovalService 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{}
- r.Options = opts
- return
-}
-
-func (r *CellApprovalService) List(ctx context.Context, cellID string, query CellApprovalListParams, opts ...option.RequestOption) (res *CellApprovalListResponse, 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/approvals", cellID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-type ApprovalRequest 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 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 RuntimeToolName `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 approvalRequestJSON `json:"-"`
-}
-
-// approvalRequestJSON contains the JSON metadata for the struct [ApprovalRequest]
-type approvalRequestJSON 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 *ApprovalRequest) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r approvalRequestJSON) RawJSON() string {
- return r.raw
-}
-
-type ApprovalRequestStatus string
-
-const (
- ApprovalRequestStatusPending ApprovalRequestStatus = "pending"
- ApprovalRequestStatusApproved ApprovalRequestStatus = "approved"
- ApprovalRequestStatusDenied ApprovalRequestStatus = "denied"
- ApprovalRequestStatusCancelled ApprovalRequestStatus = "cancelled"
- ApprovalRequestStatusTimedOut ApprovalRequestStatus = "timed_out"
-)
-
-func (r ApprovalRequestStatus) IsKnown() bool {
- switch r {
- case ApprovalRequestStatusPending, ApprovalRequestStatusApproved, ApprovalRequestStatusDenied, ApprovalRequestStatusCancelled, ApprovalRequestStatusTimedOut:
- return true
- }
- 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 {
- // 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 thread id filter.
- ThreadID param.Field[string] `query:"threadId"`
-}
-
-// URLQuery serializes [CellApprovalListParams]'s query parameters as `url.Values`.
-func (r CellApprovalListParams) URLQuery() (v url.Values) {
- return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
- ArrayFormat: apiquery.ArrayQueryFormatComma,
- NestedFormat: apiquery.NestedQueryFormatBrackets,
- })
-}
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/cellconfig_test.go b/cellconfig_test.go
deleted file mode 100644
index 2ac7047..0000000
--- a/cellconfig_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 TestCellConfigGet(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.Config.Get(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/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/cellconnection_test.go b/cellconnection_test.go
deleted file mode 100644
index c5f2e96..0000000
--- a/cellconnection_test.go
+++ /dev/null
@@ -1,93 +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 TestCellConnectionList(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.Connections.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())
- }
-}
-
-func TestCellConnectionAttachWithOptionalParams(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.Connections.Attach(
- context.TODO(),
- "cell_abc123",
- cercago.CellConnectionAttachParams{
- ConnectionID: cercago.F("connectionId"),
- Metadata: cercago.F(cercago.ToolConnectionMetadataParam{
- "foo": "string",
- }),
- },
- )
- 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 TestCellConnectionDetach(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.Connections.Detach(
- context.TODO(),
- "cell_abc123",
- "env:org_abc123:env_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())
- }
-}
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/cellcontext_test.go b/cellcontext_test.go
deleted file mode 100644
index 9d2e5c0..0000000
--- a/cellcontext_test.go
+++ /dev/null
@@ -1,75 +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 TestCellContextListWithOptionalParams(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.Context.List(
- context.TODO(),
- "cell_abc123",
- cercago.CellContextListParams{
- 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 TestCellContextSearchWithOptionalParams(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.Context.Search(
- context.TODO(),
- "cell_abc123",
- cercago.CellContextSearchParams{
- 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())
- }
-}
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.go b/celltool.go
deleted file mode 100644
index 9764520..0000000
--- a/celltool.go
+++ /dev/null
@@ -1,227 +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"
-)
-
-// CellToolService 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 {
- 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{}
- r.Options = opts
- return
-}
-
-func (r *CellToolService) List(ctx context.Context, cellID string, opts ...option.RequestOption) (res *CellToolListResponse, 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/tools", cellID)
- 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 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
-}
-
-func (r *RuntimeDiscoveredTool) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r runtimeDiscoveredToolJSON) RawJSON() string {
- return r.raw
-}
-
-type RuntimeDiscoveredToolApproval string
-
-const (
- RuntimeDiscoveredToolApprovalAlways RuntimeDiscoveredToolApproval = "always"
- RuntimeDiscoveredToolApprovalNever RuntimeDiscoveredToolApproval = "never"
-)
-
-func (r RuntimeDiscoveredToolApproval) IsKnown() bool {
- switch r {
- case RuntimeDiscoveredToolApprovalAlways, RuntimeDiscoveredToolApprovalNever:
- return true
- }
- return false
-}
-
-type RuntimeDiscoveredToolOrigin string
-
-const (
- RuntimeDiscoveredToolOriginBuiltin RuntimeDiscoveredToolOrigin = "builtin"
- RuntimeDiscoveredToolOriginToolSource RuntimeDiscoveredToolOrigin = "tool_source"
-)
-
-func (r RuntimeDiscoveredToolOrigin) IsKnown() bool {
- switch r {
- case RuntimeDiscoveredToolOriginBuiltin, RuntimeDiscoveredToolOriginToolSource:
- 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:"-"`
-}
-
-// runtimeSourceWarningJSON contains the JSON metadata for the struct
-// [RuntimeSourceWarning]
-type runtimeSourceWarningJSON struct {
- Message apijson.Field
- Source apijson.Field
- SourceID apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *RuntimeSourceWarning) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r runtimeSourceWarningJSON) RawJSON() string {
- return r.raw
-}
-
-type RuntimeToolDescriptor struct {
- Description string `json:"description" api:"required"`
- InputSchema interface{} `json:"inputSchema" api:"required"`
- Name RuntimeToolName `json:"name" api:"required"`
- JSON runtimeToolDescriptorJSON `json:"-"`
-}
-
-// runtimeToolDescriptorJSON contains the JSON metadata for the struct
-// [RuntimeToolDescriptor]
-type runtimeToolDescriptorJSON struct {
- Description apijson.Field
- InputSchema apijson.Field
- Name apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *RuntimeToolDescriptor) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-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:"-"`
-}
-
-// cellToolListResponseJSON contains the JSON metadata for the struct
-// [CellToolListResponse]
-type cellToolListResponseJSON struct {
- DiscoveredTools apijson.Field
- Tools apijson.Field
- SourceWarnings apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *CellToolListResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r cellToolListResponseJSON) RawJSON() string {
- return r.raw
-}
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..a6a714d 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"
@@ -16,25 +17,42 @@ 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
+ 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).
// 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))
}
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
}
@@ -49,9 +67,18 @@ 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.Connections = NewConnectionService(opts...)
+ r.Fleets = NewFleetService(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.Schedules = NewScheduleService(opts...)
+ r.ApprovalRequests = NewApprovalRequestService(opts...)
+ r.ApprovalGrants = NewApprovalGrantService(opts...)
+ r.Sandbox = NewSandboxService(opts...)
r.Models = NewModelService(opts...)
return
diff --git a/client_test.go b/client_test.go
index 959e5cf..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"
@@ -38,7 +39,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 +65,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 +102,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 +134,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 +165,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 +190,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 +212,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 +240,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 {
@@ -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/connection.go b/connection.go
new file mode 100644
index 0000000..6ea8d35
--- /dev/null
+++ b/connection.go
@@ -0,0 +1,609 @@
+// 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"
+)
+
+// 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
+}
+
+// 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"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// 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)
+ 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
+ }
+ err = cfg.Execute()
+ if err != nil {
+ return nil, err
+ }
+ res.SetPageConfig(cfg, raw)
+ return res, nil
+}
+
+// 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...))
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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"`
+ 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 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 ConnectionDeleteResponse struct {
+ Success ConnectionDeleteResponseSuccess `json:"success" api:"required"`
+ JSON connectionDeleteResponseJSON `json:"-"`
+}
+
+// connectionDeleteResponseJSON contains the JSON metadata for the struct
+// [ConnectionDeleteResponse]
+type connectionDeleteResponseJSON struct {
+ Success apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConnectionDeleteResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+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:"-"`
+}
+
+// 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 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" format:"uuid"`
+ Metadata param.Field[ToolConnectionMetadataParam] `json:"metadata"`
+}
+
+func (r ConnectionAttachParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/cell_test.go b/connection_test.go
similarity index 51%
rename from cell_test.go
rename to connection_test.go
index 37ac422..b711699 100644
--- a/cell_test.go
+++ b/connection_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellNewWithOptionalParams(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,25 +25,13 @@ 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.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
@@ -54,7 +42,7 @@ func TestCellNewWithOptionalParams(t *testing.T) {
}
}
-func TestCellGet(t *testing.T) {
+func TestConnectionListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -66,7 +54,12 @@ func TestCellGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Get(context.TODO(), "cell_abc123")
+ _, 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) {
@@ -76,7 +69,7 @@ func TestCellGet(t *testing.T) {
}
}
-func TestCellUpdateWithOptionalParams(t *testing.T) {
+func TestConnectionDeleteWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -88,22 +81,42 @@ func TestCellUpdateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Update(
+ _, err := client.Connections.Delete(
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"),
+ "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) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestConnectionAttachWithOptionalParams(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.Attach(
+ context.TODO(),
+ "agent_abc123",
+ cercago.ConnectionAttachParams{
+ ConnectionID: cercago.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
+ Metadata: cercago.F(cercago.ToolConnectionMetadataParam{
+ "foo": "string",
}),
},
)
@@ -116,7 +129,7 @@ func TestCellUpdateWithOptionalParams(t *testing.T) {
}
}
-func TestCellListWithOptionalParams(t *testing.T) {
+func TestConnectionDetach(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -128,12 +141,11 @@ 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.Connections.Detach(
+ context.TODO(),
+ "agent_abc123",
+ "9f063c59-2775-4614-8a68-22e5f90f92f3",
+ )
if err != nil {
var apierr *cercago.Error
if errors.As(err, &apierr) {
@@ -143,7 +155,7 @@ func TestCellListWithOptionalParams(t *testing.T) {
}
}
-func TestCellDelete(t *testing.T) {
+func TestConnectionListForAgent(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -155,7 +167,7 @@ func TestCellDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Delete(context.TODO(), "cell_abc123")
+ _, 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
new file mode 100644
index 0000000..3cee37a
--- /dev/null
+++ b/context.go
@@ -0,0 +1,326 @@
+// 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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 == "" {
+ 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/environmenttoolsource_test.go b/context_test.go
similarity index 51%
rename from environmenttoolsource_test.go
rename to context_test.go
index 1dc6ecf..229cd31 100644
--- a/environmenttoolsource_test.go
+++ b/context_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestEnvironmentToolSourceNewWithOptionalParams(t *testing.T) {
+func TestContextGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,35 +25,11 @@ func TestEnvironmentToolSourceNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.ToolSources.New(
+ _, err := client.Context.Get(
context.TODO(),
- "env_abc123",
- cercago.EnvironmentToolSourceNewParams{
- Body: cercago.EnvironmentToolSourceNewParamsBodyObject{
- Auth: cercago.F[any](map[string]interface{}{
- "kind": "none",
- }),
- 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",
- },
- }}),
- Type: cercago.F(cercago.EnvironmentToolSourceNewParamsBodyObjectTypeHTTP),
- Approval: cercago.F(cercago.ToolApprovalModeAlways),
- Enabled: cercago.F(true),
- Execution: cercago.F[any](map[string]interface{}{
- "timeoutMs": 10000,
- "maxAttempts": 3,
- "retryMode": "safe_only",
- }),
- },
+ "agent_abc123",
+ cercago.ContextGetParams{
+ Key: cercago.F("notes/project.md"),
},
)
if err != nil {
@@ -65,7 +41,7 @@ func TestEnvironmentToolSourceNewWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentToolSourceGet(t *testing.T) {
+func TestContextListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -77,10 +53,14 @@ func TestEnvironmentToolSourceGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.ToolSources.Get(
+ _, err := client.Context.List(
context.TODO(),
- "env_abc123",
- "toolsrc_abc123",
+ "agent_abc123",
+ cercago.ContextListParams{
+ Cursor: cercago.F("cursor_abc123"),
+ Limit: cercago.F("20"),
+ Prefix: cercago.F("notes/"),
+ },
)
if err != nil {
var apierr *cercago.Error
@@ -91,7 +71,7 @@ func TestEnvironmentToolSourceGet(t *testing.T) {
}
}
-func TestEnvironmentToolSourceUpdateWithOptionalParams(t *testing.T) {
+func TestContextDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -103,36 +83,11 @@ func TestEnvironmentToolSourceUpdateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.ToolSources.Update(
+ _, err := client.Context.Delete(
context.TODO(),
- "env_abc123",
- "toolsrc_abc123",
- cercago.EnvironmentToolSourceUpdateParams{
- Body: cercago.EnvironmentToolSourceUpdateParamsBodyObject{
- Auth: cercago.F[any](map[string]interface{}{
- "kind": "none",
- }),
- 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",
- },
- }}),
- Type: cercago.F(cercago.EnvironmentToolSourceUpdateParamsBodyObjectTypeHTTP),
- Approval: cercago.F(cercago.ToolApprovalModeAlways),
- Enabled: cercago.F(true),
- Execution: cercago.F[any](map[string]interface{}{
- "timeoutMs": 10000,
- "maxAttempts": 3,
- "retryMode": "safe_only",
- }),
- },
+ "agent_abc123",
+ cercago.ContextDeleteParams{
+ Key: cercago.F("notes/project.md"),
},
)
if err != nil {
@@ -144,7 +99,7 @@ func TestEnvironmentToolSourceUpdateWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentToolSourceListWithOptionalParams(t *testing.T) {
+func TestContextSearchWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -156,12 +111,14 @@ func TestEnvironmentToolSourceListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Environments.ToolSources.List(
+ _, err := client.Context.Search(
context.TODO(),
- "env_abc123",
- cercago.EnvironmentToolSourceListParams{
+ "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 {
@@ -173,7 +130,7 @@ func TestEnvironmentToolSourceListWithOptionalParams(t *testing.T) {
}
}
-func TestEnvironmentToolSourceDelete(t *testing.T) {
+func TestContextWriteWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -185,10 +142,15 @@ func TestEnvironmentToolSourceDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- err := client.Environments.ToolSources.Delete(
+ _, err := client.Context.Write(
context.TODO(),
- "env_abc123",
- "toolsrc_abc123",
+ "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
diff --git a/credential.go b/credential.go
deleted file mode 100644
index f53a378..0000000
--- a/credential.go
+++ /dev/null
@@ -1,233 +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"
-)
-
-// 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 *CredentialListResponse, 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", scope)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
- return res, err
-}
-
-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 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:"-"`
-}
-
-// 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/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}
+}
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..ee75445
--- /dev/null
+++ b/event.go
@@ -0,0 +1,3720 @@
+// 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/packages/ssestream"
+ "github.com/matrices/cerca-go/shared"
+ "github.com/tidwall/gjson"
+)
+
+// 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
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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 ssestream.NewStream[SubscriptionEvent](nil, 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)
+}
+
+// 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 ssestream.NewStream[SubscriptionEvent](nil, 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)
+}
+
+// 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 ssestream.NewStream[ThreadStreamEvent](nil, err)
+ }
+ if threadID == "" {
+ err = errors.New("missing required threadId parameter")
+ 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/stream", agentID, threadID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &raw, opts...)
+ return ssestream.NewStream[SubscriptionEvent](ssestream.NewDecoder(raw), err)
+}
+
+type RuntimeWebhookEvent struct {
+ 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
+// [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 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 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 RuntimeWebhookEventThreadStatusChangedWebhookEventEvent string
+
+const (
+ 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 RuntimeWebhookEventEventAgentCreated, RuntimeWebhookEventEventAgentUpdated, RuntimeWebhookEventEventAgentDeleted, RuntimeWebhookEventEventThreadCreated, RuntimeWebhookEventEventThreadStatusChanged, RuntimeWebhookEventEventThreadCompleted, RuntimeWebhookEventEventThreadFailed, RuntimeWebhookEventEventTurnCreated, RuntimeWebhookEventEventTurnCompleted, RuntimeWebhookEventEventTurnFailed, RuntimeWebhookEventEventMessageCreated, RuntimeWebhookEventEventApprovalRequested, RuntimeWebhookEventEventApprovalResolved, RuntimeWebhookEventEventApprovalGranted, RuntimeWebhookEventEventScheduleCreated, RuntimeWebhookEventEventScheduleDeleted, RuntimeWebhookEventEventScheduleTriggered, RuntimeWebhookEventEventConnectionAttached, RuntimeWebhookEventEventConnectionDetached, RuntimeWebhookEventEventWebhookTest:
+ 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 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
+}
+
+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)
+}
+
+// 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 (
+ ThreadStreamEventThreadStreamStatusMessageTypeStatus ThreadStreamEventThreadStreamStatusMessageType = "status"
+)
+
+func (r ThreadStreamEventThreadStreamStatusMessageType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamStatusMessageTypeStatus:
+ return true
+ }
+ return false
+}
+
+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:"-"`
+}
+
+// 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
+}
+
+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 (
+ ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockTypeText ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockType = "text"
+)
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockType) IsKnown() bool {
+ switch r {
+ case ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamTextContentBlockTypeText:
+ return true
+ }
+ return false
+}
+
+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:"-"`
+}
+
+// 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
+}
+
+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 (
+ ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockTypeToolUse ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockType = "tool_use"
+)
+
+func (r ThreadStreamEventThreadStreamContentMessageMessageContentThreadStreamToolUseContentBlockType) IsKnown() bool {
+ switch r {
+ 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/cellcontextentry_test.go b/event_test.go
similarity index 61%
rename from cellcontextentry_test.go
rename to event_test.go
index 8df263b..814aae7 100644
--- a/cellcontextentry_test.go
+++ b/event_test.go
@@ -13,7 +13,7 @@ import (
"github.com/matrices/cerca-go/option"
)
-func TestCellContextEntryGet(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,11 +25,14 @@ func TestCellContextEntryGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Context.Entries.Get(
+ _, err := client.Events.ListForAgent(
context.TODO(),
- "cell_abc123",
- cercago.CellContextEntryGetParams{
- Key: cercago.F("notes/project.md"),
+ "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 {
@@ -41,7 +44,7 @@ func TestCellContextEntryGet(t *testing.T) {
}
}
-func TestCellContextEntryDelete(t *testing.T) {
+func TestEventListForFleetWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -53,11 +56,14 @@ func TestCellContextEntryDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Context.Entries.Delete(
+ _, err := client.Events.ListForFleet(
context.TODO(),
- "cell_abc123",
- cercago.CellContextEntryDeleteParams{
- Key: cercago.F("notes/project.md"),
+ "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 {
@@ -69,7 +75,7 @@ func TestCellContextEntryDelete(t *testing.T) {
}
}
-func TestCellContextEntryPutWithOptionalParams(t *testing.T) {
+func TestEventListForThreadWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -81,14 +87,15 @@ func TestCellContextEntryPutWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- _, err := client.Cells.Context.Entries.Put(
+ _, err := client.Events.ListForThread(
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",
+ 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 {
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/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,
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
diff --git a/model.go b/model.go
index 9d3a4ea..6a5235d 100644
--- a/model.go
+++ b/model.go
@@ -31,6 +31,7 @@ func NewModelService(opts ...option.RequestOption) (r *ModelService) {
return
}
+// 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 0c32cc4..439d07a 100644
--- a/oauth.go
+++ b/oauth.go
@@ -34,6 +34,7 @@ func NewOAuthService(opts ...option.RequestOption) (r *OAuthService) {
return
}
+// 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 == "" {
@@ -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 95c068d..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:env_abc123"),
Scopes: cercago.F([]string{"email", "profile"}),
},
)
diff --git a/packages/pagination/pagination.go b/packages/pagination/pagination.go
index 6778d4b..e8bc7ef 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,1154 @@ 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 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
+}
+
+// approvalRequestsCursorPageJSON contains the JSON metadata for the struct
+// [ApprovalRequestsCursorPage[T]]
+type approvalRequestsCursorPageJSON struct {
+ Approvals apijson.Field
+ Cursor apijson.Field
+ HasMore apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ApprovalRequestsCursorPage[T]) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+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 *ApprovalRequestsCursorPage[T]) GetNextPage() (res *ApprovalRequestsCursorPage[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 *ApprovalRequestsCursorPage[T]) SetPageConfig(cfg *requestconfig.RequestConfig, res *http.Response) {
+ if r == nil {
+ r = &ApprovalRequestsCursorPage[T]{}
+ }
+ r.cfg = cfg
+ r.res = res
+}
+
+type ApprovalRequestsCursorPageAutoPager[T any] struct {
+ page *ApprovalRequestsCursorPage[T]
+ cur T
+ idx int
+ run int
+ err error
+}
+
+func NewApprovalRequestsCursorPageAutoPager[T any](page *ApprovalRequestsCursorPage[T], err error) *ApprovalRequestsCursorPageAutoPager[T] {
+ return &ApprovalRequestsCursorPageAutoPager[T]{
+ page: page,
+ err: err,
+ }
+}
+
+func (r *ApprovalRequestsCursorPageAutoPager[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 *ApprovalRequestsCursorPageAutoPager[T]) Current() T {
+ return r.cur
+}
+
+func (r *ApprovalRequestsCursorPageAutoPager[T]) Err() error {
+ return r.err
+}
+
+func (r *ApprovalRequestsCursorPageAutoPager[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 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/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/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..77c647f
--- /dev/null
+++ b/sandbox.go
@@ -0,0 +1,207 @@
+// 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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..20aa089
--- /dev/null
+++ b/schedule.go
@@ -0,0 +1,267 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package cercago
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "slices"
+ "time"
+
+ "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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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 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:"-"`
+}
+
+// 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
+ 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
+}
+
+func (r *Schedule) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r scheduleJSON) RawJSON() string {
+ return r.raw
+}
+
+type ScheduleListResponse struct {
+ Schedules []Schedule `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 {
+ 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) {
+ 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"`
+ 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) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/cellschedule_test.go b/schedule_test.go
similarity index 76%
rename from cellschedule_test.go
rename to schedule_test.go
index 38fcb78..c5cc915 100644
--- a/cellschedule_test.go
+++ b/schedule_test.go
@@ -7,13 +7,15 @@ import (
"errors"
"os"
"testing"
+ "time"
"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 +27,18 @@ 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{
- Cron: cercago.F("cron"),
+ "agent_abc123",
+ cercago.ScheduleNewParams{
+ Message: cercago.F("message"),
Name: cercago.F("name"),
- Prompt: cercago.F("prompt"),
- Features: cercago.F([]cercago.CellScheduleNewParamsFeature{cercago.CellScheduleNewParamsFeatureMemory}),
+ 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.*"}),
},
)
if err != nil {
@@ -47,7 +50,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 +62,20 @@ 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"),
+ 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.*"}),
},
)
if err != nil {
@@ -83,7 +87,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 +99,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 +109,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 +121,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 +135,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 +147,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..cad30fe
--- /dev/null
+++ b/shared/shared.go
@@ -0,0 +1,72 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package shared
+
+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 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..892e5a7
--- /dev/null
+++ b/thread.go
@@ -0,0 +1,1064 @@
+// 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 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:"-"`
+}
+
+// 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 *ContentBlockTextContentBlock) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r contentBlockTextContentBlockJSON) RawJSON() string {
+ return r.raw
+}
+
+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 (
+ ContentBlockServerToolUseContentBlockTypeServerToolUse ContentBlockServerToolUseContentBlockType = "server_tool_use"
+)
+
+func (r ContentBlockServerToolUseContentBlockType) IsKnown() bool {
+ switch r {
+ 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
+}
+
+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
+}
+
+// `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 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"`
+ 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 []SubThreadSummary `json:"subThreads" api:"required"`
+ Tools []shared.ToolName `json:"tools" api:"required"`
+ Turns []Turn `json:"turns" api:"required"`
+ UpdatedAt string `json:"updatedAt" 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
+ CompiledContext apijson.Field
+ CompletedAt apijson.Field
+ CreatedAt apijson.Field
+ Depth apijson.Field
+ Error apijson.Field
+ Instructions apijson.Field
+ LastTurnStatus apijson.Field
+ Message apijson.Field
+ Messages apijson.Field
+ Model apijson.Field
+ ParentThreadID 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
+ 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"`
+ 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"`
+ 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"`
+ 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
+ Message apijson.Field
+ Result apijson.Field
+ Seq apijson.Field
+ StartedAt apijson.Field
+ StartMessageSeq apijson.Field
+ Status apijson.Field
+ ThreadID apijson.Field
+ TokenUsage 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"`
+ 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"`
+ // 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) {
+ 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 {
+ 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) {
+ 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 74%
rename from cellthread_test.go
rename to thread_test.go
index 1a2cc6e..3317281 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,15 +26,15 @@ 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"),
+ Message: cercago.F("message"),
Model: cercago.F("model"),
SystemPrompt: cercago.F("systemPrompt"),
- UserMessage: cercago.F("userMessage"),
+ Tools: cercago.F([]shared.ToolSpecParam{"sandbox.*"}),
},
)
if err != nil {
@@ -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{
+ cercago.ThreadStartTurnParams{
Message: cercago.F("message"),
+ 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/tool.go b/tool.go
new file mode 100644
index 0000000..15f092c
--- /dev/null
+++ b/tool.go
@@ -0,0 +1,1749 @@
+// 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"
+)
+
+// 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 [NewToolService] method instead.
+type ToolService struct {
+ Options []option.RequestOption
+}
+
+// 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
+}
+
+// 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/tools", fleetID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return res, err
+}
+
+// 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 == "" {
+ 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/tools/%s", fleetID, sourceID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return res, err
+}
+
+// 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 == "" {
+ 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/tools/%s", fleetID, sourceID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &res, opts...)
+ return res, err
+}
+
+// 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)
+ 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/tools", 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
+}
+
+// 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...))
+}
+
+// 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...)
+ 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/tools/%s", fleetID, sourceID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
+ 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 {
+ 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 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 authInjectionQueryAuthInjectionJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r AuthInjectionQueryAuthInjection) implementsAuthInjection() {}
+
+type AuthInjectionQueryAuthInjectionLocation string
+
+const (
+ AuthInjectionQueryAuthInjectionLocationQuery AuthInjectionQueryAuthInjectionLocation = "query"
+)
+
+func (r AuthInjectionQueryAuthInjectionLocation) IsKnown() bool {
+ switch r {
+ case AuthInjectionQueryAuthInjectionLocationQuery:
+ return true
+ }
+ return false
+}
+
+type AuthInjectionLocation string
+
+const (
+ AuthInjectionLocationHeader AuthInjectionLocation = "header"
+ AuthInjectionLocationQuery AuthInjectionLocation = "query"
+)
+
+func (r AuthInjectionLocation) IsKnown() bool {
+ switch r {
+ case AuthInjectionLocationHeader, AuthInjectionLocationQuery:
+ return true
+ }
+ return false
+}
+
+// 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)
+}
+
+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 *HTTPEndpoint) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r httpEndpointJSON) RawJSON() string {
+ return r.raw
+}
+
+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:"-"`
+}
+
+// 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 *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 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 {
+ 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
+}
+
+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:"-"`
+}
+
+// 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 *OAuthExchangeConfigClientCredentialsOAuthExchange) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+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() {}
+
+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"`
+ 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 [NoToolSourceAuth],
+// [APIKeyToolSourceAuth], [OAuthExchangeToolSourceAuth],
+// [OAuthConnectionToolSourceAuth].
+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 [NoToolSourceAuth], [APIKeyToolSourceAuth],
+// [OAuthExchangeToolSourceAuth] or [OAuthConnectionToolSourceAuth].
+type ToolSourceAuthUnion interface {
+ implementsToolSourceAuth()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*ToolSourceAuthUnion)(nil)).Elem(),
+ "kind",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(NoToolSourceAuth{}),
+ DiscriminatorValue: "none",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(APIKeyToolSourceAuth{}),
+ DiscriminatorValue: "api_key",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(OAuthExchangeToolSourceAuth{}),
+ DiscriminatorValue: "oauth_exchange",
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(OAuthConnectionToolSourceAuth{}),
+ DiscriminatorValue: "oauth_connection",
+ },
+ )
+}
+
+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 [NoToolSourceAuthParam], [APIKeyToolSourceAuthParam],
+// [OAuthExchangeToolSourceAuthParam], [OAuthConnectionToolSourceAuthParam],
+// [ToolSourceAuthParam].
+type ToolSourceAuthUnionParam interface {
+ implementsToolSourceAuthUnionParam()
+}
+
+type ToolNewParams struct {
+ Body ToolNewParamsBodyUnion `json:"body" api:"required"`
+}
+
+func (r ToolNewParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r.Body)
+}
+
+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[ToolNewParamsBodyType] `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 ToolNewParamsBody) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolNewParamsBody) implementsToolNewParamsBodyUnion() {}
+
+// Satisfied by [ToolNewParamsBodyCreateHTTPToolSourceRequest],
+// [ToolNewParamsBodyCreateMcpToolSourceRequest], [ToolNewParamsBody].
+type ToolNewParamsBodyUnion interface {
+ implementsToolNewParamsBodyUnion()
+}
+
+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[ToolNewParamsBodyCreateHTTPToolSourceRequestType] `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 ToolNewParamsBodyCreateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolNewParamsBodyCreateHTTPToolSourceRequest) implementsToolNewParamsBodyUnion() {}
+
+type ToolNewParamsBodyCreateHTTPToolSourceRequestType string
+
+const (
+ ToolNewParamsBodyCreateHTTPToolSourceRequestTypeHTTP ToolNewParamsBodyCreateHTTPToolSourceRequestType = "http"
+)
+
+func (r ToolNewParamsBodyCreateHTTPToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolNewParamsBodyCreateHTTPToolSourceRequestTypeHTTP:
+ return true
+ }
+ return false
+}
+
+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[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"`
+ // MCP discovery and execution retry/timeout policy.
+ Execution param.Field[McpToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolNewParamsBodyCreateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolNewParamsBodyCreateMcpToolSourceRequest) implementsToolNewParamsBodyUnion() {}
+
+type ToolNewParamsBodyCreateMcpToolSourceRequestType string
+
+const (
+ ToolNewParamsBodyCreateMcpToolSourceRequestTypeMcp ToolNewParamsBodyCreateMcpToolSourceRequestType = "mcp"
+)
+
+func (r ToolNewParamsBodyCreateMcpToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolNewParamsBodyCreateMcpToolSourceRequestTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolNewParamsBodyType string
+
+const (
+ ToolNewParamsBodyTypeHTTP ToolNewParamsBodyType = "http"
+ ToolNewParamsBodyTypeMcp ToolNewParamsBodyType = "mcp"
+)
+
+func (r ToolNewParamsBodyType) IsKnown() bool {
+ switch r {
+ case ToolNewParamsBodyTypeHTTP, ToolNewParamsBodyTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolUpdateParams struct {
+ Body ToolUpdateParamsBodyUnion `json:"body" api:"required"`
+}
+
+func (r ToolUpdateParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r.Body)
+}
+
+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[ToolUpdateParamsBodyType] `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 ToolUpdateParamsBody) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolUpdateParamsBody) implementsToolUpdateParamsBodyUnion() {}
+
+// Satisfied by [ToolUpdateParamsBodyUpdateHTTPToolSourceRequest],
+// [ToolUpdateParamsBodyUpdateMcpToolSourceRequest], [ToolUpdateParamsBody].
+type ToolUpdateParamsBodyUnion interface {
+ implementsToolUpdateParamsBodyUnion()
+}
+
+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[ToolUpdateParamsBodyUpdateHTTPToolSourceRequestType] `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 ToolUpdateParamsBodyUpdateHTTPToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolUpdateParamsBodyUpdateHTTPToolSourceRequest) implementsToolUpdateParamsBodyUnion() {}
+
+type ToolUpdateParamsBodyUpdateHTTPToolSourceRequestType string
+
+const (
+ ToolUpdateParamsBodyUpdateHTTPToolSourceRequestTypeHTTP ToolUpdateParamsBodyUpdateHTTPToolSourceRequestType = "http"
+)
+
+func (r ToolUpdateParamsBodyUpdateHTTPToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolUpdateParamsBodyUpdateHTTPToolSourceRequestTypeHTTP:
+ return true
+ }
+ return false
+}
+
+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[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"`
+ // MCP discovery and execution retry/timeout policy.
+ Execution param.Field[McpToolExecutionPolicyParam] `json:"execution"`
+ ExtraFields map[string]interface{} `json:"-,extras"`
+}
+
+func (r ToolUpdateParamsBodyUpdateMcpToolSourceRequest) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r ToolUpdateParamsBodyUpdateMcpToolSourceRequest) implementsToolUpdateParamsBodyUnion() {}
+
+type ToolUpdateParamsBodyUpdateMcpToolSourceRequestType string
+
+const (
+ ToolUpdateParamsBodyUpdateMcpToolSourceRequestTypeMcp ToolUpdateParamsBodyUpdateMcpToolSourceRequestType = "mcp"
+)
+
+func (r ToolUpdateParamsBodyUpdateMcpToolSourceRequestType) IsKnown() bool {
+ switch r {
+ case ToolUpdateParamsBodyUpdateMcpToolSourceRequestTypeMcp:
+ return true
+ }
+ return false
+}
+
+type ToolUpdateParamsBodyType string
+
+const (
+ ToolUpdateParamsBodyTypeHTTP ToolUpdateParamsBodyType = "http"
+ ToolUpdateParamsBodyTypeMcp ToolUpdateParamsBodyType = "mcp"
+)
+
+func (r ToolUpdateParamsBodyType) IsKnown() bool {
+ switch r {
+ case ToolUpdateParamsBodyTypeHTTP, ToolUpdateParamsBodyTypeMcp:
+ 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
new file mode 100644
index 0000000..30be93e
--- /dev/null
+++ b/tool_test.go
@@ -0,0 +1,242 @@
+// 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 TestToolNewWithOptionalParams(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.New(
+ context.TODO(),
+ "fleet_abc123",
+ cercago.ToolNewParams{
+ Body: cercago.ToolNewParamsBodyCreateHTTPToolSourceRequest{
+ Auth: cercago.F[cercago.ToolSourceAuthUnionParam](cercago.NoToolSourceAuthParam{
+ Kind: cercago.F(cercago.NoToolSourceAuthKindNone),
+ }),
+ 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.ToolNewParamsBodyCreateHTTPToolSourceRequestTypeHTTP),
+ 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{
+ Body: cercago.ToolUpdateParamsBodyUpdateHTTPToolSourceRequest{
+ Auth: cercago.F[cercago.ToolSourceAuthUnionParam](cercago.NoToolSourceAuthParam{
+ Kind: cercago.F(cercago.NoToolSourceAuthKindNone),
+ }),
+ 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.ToolUpdateParamsBodyUpdateHTTPToolSourceRequestTypeHTTP),
+ 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) {
+ 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..801cd44 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -24,11 +24,11 @@ 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{
- UserMessage: cercago.F("What's on my calendar today?"),
+ "agent_abc123",
+ cercago.ThreadNewParams{
+ Message: cercago.F("What's on my calendar today?"),
},
)
if err != nil {
diff --git a/webhook.go b/webhook.go
new file mode 100644
index 0000000..583b841
--- /dev/null
+++ b/webhook.go
@@ -0,0 +1,363 @@
+// 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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)
+ 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
+}
+
+// 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...))
+}
+
+// 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...)
+ 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
+}
+
+// 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 == "" {
+ 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
+}
+
+// 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 == "" {
+ 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 {