Class: Cadenya::Resources::Agents

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/agents.rb,
lib/cadenya/resources/agents/feedback.rb,
lib/cadenya/resources/agents/schedules.rb,
lib/cadenya/resources/agents/variations.rb,
lib/cadenya/resources/agents/webhook_deliveries.rb

Overview

Manage AI agents within a workspace. Agents define AI behavior and tool access.

Defined Under Namespace

Classes: Feedback, Schedules, Variations, WebhookDeliveries

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Agents

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Agents.

Parameters:



206
207
208
209
210
211
212
# File 'lib/cadenya/resources/agents.rb', line 206

def initialize(client:)
  @client = client
  @feedback = Cadenya::Resources::Agents::Feedback.new(client: client)
  @webhook_deliveries = Cadenya::Resources::Agents::WebhookDeliveries.new(client: client)
  @variations = Cadenya::Resources::Agents::Variations.new(client: client)
  @schedules = Cadenya::Resources::Agents::Schedules.new(client: client)
end

Instance Attribute Details

#feedbackCadenya::Resources::Agents::Feedback (readonly)

Manage AI agents within a workspace. Agents define AI behavior and tool access.



9
10
11
# File 'lib/cadenya/resources/agents.rb', line 9

def feedback
  @feedback
end

#schedulesCadenya::Resources::Agents::Schedules (readonly)

Manage recurring schedules attached to agents. Schedules trigger objectives on a cadence defined by AgentScheduleSpec.Schedule.



23
24
25
# File 'lib/cadenya/resources/agents.rb', line 23

def schedules
  @schedules
end

#variationsCadenya::Resources::Agents::Variations (readonly)

Manage variations of an agent and their tool, sub-agent, and memory layer assignments.



18
19
20
# File 'lib/cadenya/resources/agents.rb', line 18

def variations
  @variations
end

#webhook_deliveriesCadenya::Resources::Agents::WebhookDeliveries (readonly)

Manage AI agents within a workspace. Agents define AI behavior and tool access.



13
14
15
# File 'lib/cadenya/resources/agents.rb', line 13

def webhook_deliveries
  @webhook_deliveries
end

Instance Method Details

#create(workspace_id, metadata:, spec:, default_variation: nil, request_options: {}) ⇒ Cadenya::Models::Agent

Some parameter documentations has been truncated, see Models::AgentCreateParams for more details.

Creates a new agent in the workspace

Parameters:

Returns:

See Also:



45
46
47
48
49
50
51
52
53
54
# File 'lib/cadenya/resources/agents.rb', line 45

def create(workspace_id, params)
  parsed, options = Cadenya::AgentCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/agents", workspace_id],
    body: parsed,
    model: Cadenya::Agent,
    options: options
  )
end

#delete(id, workspace_id:, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::AgentDeleteParams for more details.

Deletes an agent from the workspace

Parameters:

  • id (String)

    Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<value>` form

  • workspace_id (String)

    Workspace ID.

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/cadenya/resources/agents.rb', line 189

def delete(id, params)
  parsed, options = Cadenya::AgentDeleteParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v1/workspaces/%1$s/agents/%2$s", workspace_id, id],
    model: NilClass,
    options: options
  )
end

#list(workspace_id, bundle_key: nil, cursor: nil, include_info: nil, limit: nil, prefix: nil, query: nil, sort_order: nil, status: nil, variation_selection_mode: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::Agent>

Some parameter documentations has been truncated, see Models::AgentListParams for more details.

Lists all agents in the workspace

Parameters:

  • workspace_id (String)

    Workspace ID.

  • bundle_key (String)

    Filter by bundle_key — return only resources owned by this bundle.

  • cursor (String)

    Pagination cursor from previous response

  • include_info (Boolean)

    When true, the ‘info` field on each returned agent is populated. Requests

  • limit (Integer)

    Maximum number of results to return

  • prefix (String)

    Filter expression (query param: prefix)

  • query (String)

    Free-form search query

  • sort_order (String)

    Sort order for results (asc or desc by creation time)

  • status (Symbol, Cadenya::Models::AgentListParams::Status)

    Filter by agent publication status

  • variation_selection_mode (Symbol, Cadenya::Models::AgentListParams::VariationSelectionMode)

    Filter by variation selection mode

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/cadenya/resources/agents.rb', line 155

def list(workspace_id, params = {})
  parsed, options = Cadenya::AgentListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/agents", workspace_id],
    query: query.transform_keys(
      bundle_key: "bundleKey",
      include_info: "includeInfo",
      sort_order: "sortOrder",
      variation_selection_mode: "variationSelectionMode"
    ),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::Agent,
    options: options
  )
end

#retrieve(id, workspace_id:, request_options: {}) ⇒ Cadenya::Models::Agent

Some parameter documentations has been truncated, see Models::AgentRetrieveParams for more details.

Retrieves an agent by ID from the workspace

Parameters:

  • id (String)

    Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<value>` form

  • workspace_id (String)

    Workspace ID.

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cadenya/resources/agents.rb', line 72

def retrieve(id, params)
  parsed, options = Cadenya::AgentRetrieveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/agents/%2$s", workspace_id, id],
    model: Cadenya::Agent,
    options: options
  )
end

#update(id, workspace_id:, metadata: nil, spec: nil, update_mask: nil, request_options: {}) ⇒ Cadenya::Models::Agent

Some parameter documentations has been truncated, see Models::AgentUpdateParams for more details.

Updates an agent in the workspace

Parameters:

  • id (String)

    Path param: Agent ID. Accepts the canonical ‘agent_…` form or the `external_id:<

  • workspace_id (String)

    Path param: Workspace ID.

  • metadata (Cadenya::Models::UpdateResourceMetadata)

    Body param: UpdateResourceMetadata contains the user-provided fields for updatin

  • spec (Cadenya::Models::AgentSpec)

    Body param: Agent specification (user-provided configuration)

  • update_mask (String)

    Body param: Fields to update

  • request_options (Cadenya::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/cadenya/resources/agents.rb', line 108

def update(id, params)
  parsed, options = Cadenya::AgentUpdateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["v1/workspaces/%1$s/agents/%2$s", workspace_id, id],
    body: parsed,
    model: Cadenya::Agent,
    options: options
  )
end