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,
sig/cadenya/resources/agents.rbs,
sig/cadenya/resources/agents/feedback.rbs,
sig/cadenya/resources/agents/schedules.rbs,
sig/cadenya/resources/agents/variations.rbs,
sig/cadenya/resources/agents/webhook_deliveries.rbs

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:



337
338
339
340
341
342
343
# File 'lib/cadenya/resources/agents.rb', line 337

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

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

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

Transitions an agent to STATE_ARCHIVED. Archived agents are hidden from list results and cannot be used for objectives; active schedules are paused.

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:



227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/cadenya/resources/agents.rb', line 227

def archive(id, params = {})
  parsed, options = Cadenya::AgentArchiveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/agents/%2$s:archive", workspace_id, id],
    model: Cadenya::Agent,
    options: options
  )
end

#create(metadata:, spec:, workspace_id: nil, 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
55
56
57
58
# File 'lib/cadenya/resources/agents.rb', line 45

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

#delete(id, workspace_id: nil, 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:



196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/cadenya/resources/agents.rb', line 196

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

#list(workspace_id: nil, cursor: nil, include_info: nil, labels: nil, limit: nil, prefix: nil, query: nil, sort_order: nil, state: 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)

    Path param: Workspace ID.

  • cursor (String)

    Query param: Pagination cursor from previous response

  • include_info (Boolean)

    Query param: When true, the info field on each returned agent is populated. Re

  • labels (String)

    Query param: Filters by metadata labels. Comma-separated key=value pairs,

  • limit (Integer)

    Query param: Maximum number of results to return

  • prefix (String)

    Query param: Filter expression (query param: prefix)

  • query (String)

    Query param: Free-form search query

  • sort_order (String)

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

  • state (Symbol, Cadenya::Models::AgentListParams::State)

    Query param: Filter by agent lifecycle state

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

    Query param: Filter by variation selection mode

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

Returns:

See Also:



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/cadenya/resources/agents.rb', line 159

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

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

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

Transitions an agent to STATE_PUBLISHED, making it available for objectives. The agent must have at least one variation.

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:



258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/cadenya/resources/agents.rb', line 258

def publish(id, params = {})
  parsed, options = Cadenya::AgentPublishParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/agents/%2$s:publish", workspace_id, id],
    model: Cadenya::Agent,
    options: options
  )
end

#retrieve(id, workspace_id: nil, 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:



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/cadenya/resources/agents.rb', line 76

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

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

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

Transitions an archived agent back to STATE_DRAFT. Publish the agent again to make it available for objectives.

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:



289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/cadenya/resources/agents.rb', line 289

def unarchive(id, params = {})
  parsed, options = Cadenya::AgentUnarchiveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/agents/%2$s:unarchive", workspace_id, id],
    model: Cadenya::Agent,
    options: options
  )
end

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

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

Transitions a published agent back to STATE_DRAFT. Active schedules for the agent are paused until it is published again.

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:



320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/cadenya/resources/agents.rb', line 320

def unpublish(id, params = {})
  parsed, options = Cadenya::AgentUnpublishParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/agents/%2$s:unpublish", workspace_id, id],
    model: Cadenya::Agent,
    options: options
  )
end

#update(id, workspace_id: nil, 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:



112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/cadenya/resources/agents.rb', line 112

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