Class: Cadenya::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Cadenya::Client
- Defined in:
- lib/cadenya/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
-
#account ⇒ Cadenya::Resources::Account
readonly
Manage the authenticated account.
-
#agents ⇒ Cadenya::Resources::Agents
readonly
Manage AI agents within a workspace.
- #api_key ⇒ String readonly
-
#api_keys ⇒ Cadenya::Resources::APIKeys
readonly
Issue, rotate, and revoke API keys for the account, and grant or revoke each key’s access to individual workspaces.
-
#bulk_workspace_resources ⇒ Cadenya::Resources::BulkWorkspaceResources
readonly
Apply a declarative bundle of workspace resources — tool sets, memory layers, agents, variations, assignments, and schedules — in a single asynchronous operation.
-
#memory_layers ⇒ Cadenya::Resources::MemoryLayers
readonly
Manage memory layers and their entries.
-
#models ⇒ Cadenya::Resources::Models
readonly
Manage LLM models available to a workspace.
- #objectives ⇒ Cadenya::Resources::Objectives readonly
- #search ⇒ Cadenya::Resources::Search readonly
-
#tool_sets ⇒ Cadenya::Resources::ToolSets
readonly
Manage tool sets and the tools they contain.
-
#uploads ⇒ Cadenya::Resources::Uploads
readonly
Issue short-lived presigned URLs for direct client-to-object-storage uploads.
- #webhook_key ⇒ String? readonly
- #webhooks ⇒ Cadenya::Resources::Webhooks readonly
- #workspace_secrets ⇒ Cadenya::Resources::WorkspaceSecrets readonly
-
#workspaces ⇒ Cadenya::Resources::Workspaces
readonly
Manage workspaces within an account.
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#initialize(api_key: ENV["CADENYA_API_KEY"], webhook_key: ENV["CADENYA_WEBHOOK_KEY"], base_url: ENV["CADENYA_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["CADENYA_API_KEY"], webhook_key: ENV["CADENYA_WEBHOOK_KEY"], base_url: ENV["CADENYA_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/cadenya/client.rb', line 113 def initialize( api_key: ENV["CADENYA_API_KEY"], webhook_key: ENV["CADENYA_WEBHOOK_KEY"], base_url: ENV["CADENYA_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= "https://api.cadenya.com" if api_key.nil? raise ArgumentError.new("api_key is required, and can be set via environ: \"CADENYA_API_KEY\"") end headers = {} custom_headers_env = ENV["CADENYA_CUSTOM_HEADERS"] unless custom_headers_env.nil? parsed = {} custom_headers_env.split("\n").each do |line| colon = line.index(":") unless colon.nil? parsed[line[0...colon].strip] = line[(colon + 1)..].strip end end headers = parsed.merge(headers) end @api_key = api_key.to_s @webhook_key = webhook_key&.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay, headers: headers ) @account = Cadenya::Resources::Account.new(client: self) @agents = Cadenya::Resources::Agents.new(client: self) @objectives = Cadenya::Resources::Objectives.new(client: self) @memory_layers = Cadenya::Resources::MemoryLayers.new(client: self) @uploads = Cadenya::Resources::Uploads.new(client: self) @models = Cadenya::Resources::Models.new(client: self) @search = Cadenya::Resources::Search.new(client: self) @tool_sets = Cadenya::Resources::ToolSets.new(client: self) @api_keys = Cadenya::Resources::APIKeys.new(client: self) @workspace_secrets = Cadenya::Resources::WorkspaceSecrets.new(client: self) @workspaces = Cadenya::Resources::Workspaces.new(client: self) @webhooks = Cadenya::Resources::Webhooks.new(client: self) @bulk_workspace_resources = Cadenya::Resources::BulkWorkspaceResources.new(client: self) end |
Instance Attribute Details
#account ⇒ Cadenya::Resources::Account (readonly)
Manage the authenticated account. Accounts are the top-level organizational unit and contain one or more workspaces.
27 28 29 |
# File 'lib/cadenya/client.rb', line 27 def account @account end |
#agents ⇒ Cadenya::Resources::Agents (readonly)
Manage AI agents within a workspace. Agents define AI behavior and tool access.
31 32 33 |
# File 'lib/cadenya/client.rb', line 31 def agents @agents end |
#api_key ⇒ String (readonly)
19 20 21 |
# File 'lib/cadenya/client.rb', line 19 def api_key @api_key end |
#api_keys ⇒ Cadenya::Resources::APIKeys (readonly)
Issue, rotate, and revoke API keys for the account, and grant or revoke each key’s access to individual workspaces.
69 70 71 |
# File 'lib/cadenya/client.rb', line 69 def api_keys @api_keys end |
#bulk_workspace_resources ⇒ Cadenya::Resources::BulkWorkspaceResources (readonly)
Apply a declarative bundle of workspace resources — tool sets, memory layers, agents, variations, assignments, and schedules — in a single asynchronous operation.
86 87 88 |
# File 'lib/cadenya/client.rb', line 86 def bulk_workspace_resources @bulk_workspace_resources end |
#memory_layers ⇒ Cadenya::Resources::MemoryLayers (readonly)
Manage memory layers and their entries. Layers are named containers that can be composed into an objective’s memory stack; entries are the keyed values within a layer. System-managed layers (e.g., episodic layers created by the runtime) cannot be mutated through this API.
41 42 43 |
# File 'lib/cadenya/client.rb', line 41 def memory_layers @memory_layers end |
#models ⇒ Cadenya::Resources::Models (readonly)
Manage LLM models available to a workspace. Models represent provider and family pairs (e.g., “anthropic/claude-sonnet-4.6”). Workspaces are seeded with the supported models and you can enable or disable each one.
53 54 55 |
# File 'lib/cadenya/client.rb', line 53 def models @models end |
#objectives ⇒ Cadenya::Resources::Objectives (readonly)
34 35 36 |
# File 'lib/cadenya/client.rb', line 34 def objectives @objectives end |
#search ⇒ Cadenya::Resources::Search (readonly)
56 57 58 |
# File 'lib/cadenya/client.rb', line 56 def search @search end |
#tool_sets ⇒ Cadenya::Resources::ToolSets (readonly)
Manage tool sets and the tools they contain. Tool sets group related tools, and tools define specific capabilities available to agents.
When a tool set is managed, only API key actors can modify its tools; human (profile) actors cannot.
64 65 66 |
# File 'lib/cadenya/client.rb', line 64 def tool_sets @tool_sets end |
#uploads ⇒ Cadenya::Resources::Uploads (readonly)
Issue short-lived presigned URLs for direct client-to-object-storage uploads. Created uploads can be referenced by id when creating or updating resources that accept binary content (e.g., MemoryEntry).
47 48 49 |
# File 'lib/cadenya/client.rb', line 47 def uploads @uploads end |
#webhook_key ⇒ String? (readonly)
22 23 24 |
# File 'lib/cadenya/client.rb', line 22 def webhook_key @webhook_key end |
#webhooks ⇒ Cadenya::Resources::Webhooks (readonly)
80 81 82 |
# File 'lib/cadenya/client.rb', line 80 def webhooks @webhooks end |
#workspace_secrets ⇒ Cadenya::Resources::WorkspaceSecrets (readonly)
72 73 74 |
# File 'lib/cadenya/client.rb', line 72 def workspace_secrets @workspace_secrets end |
#workspaces ⇒ Cadenya::Resources::Workspaces (readonly)
Manage workspaces within an account. Workspaces provide organizational grouping and isolation for resources such as agents, tools, and API keys.
77 78 79 |
# File 'lib/cadenya/client.rb', line 77 def workspaces @workspaces end |