Class: Anthropic::Resources::Beta::Environments::Work
- Inherits:
-
Object
- Object
- Anthropic::Resources::Beta::Environments::Work
- Defined in:
- lib/anthropic/resources/beta/environments/work.rb,
sig/anthropic/resources/beta/environments/work.rbs
Instance Method Summary collapse
-
#ack(work_id, environment_id:, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork
Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments.
-
#heartbeat(work_id, environment_id:, desired_ttl_seconds: nil, expected_last_heartbeat: nil, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWorkHeartbeatResponse
Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments.
-
#initialize(client:) ⇒ Work
constructor
private
A new instance of Work.
-
#list(environment_id, limit: nil, page: nil, betas: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Beta::Environments::BetaSelfHostedWork>
List work items in an environment.
-
#poll(environment_id, block_ms: nil, reclaim_older_than_ms: nil, betas: nil, anthropic_worker_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork?
Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments.
-
#retrieve(work_id, environment_id:, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork
Retrieve detailed information about a specific work item.
-
#stats(environment_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWorkQueueStats
Get statistics about the work queue for an environment.
-
#stop(work_id, environment_id:, force: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork
Stop a work item, initiating graceful or forced shutdown.
-
#update(work_id, environment_id:, metadata:, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork
Update work item metadata with merge semantics.
Constructor Details
#initialize(client:) ⇒ Work
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 Work.
396 397 398 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 396 def initialize(client:) @client = client end |
Instance Method Details
#ack(work_id, environment_id:, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork
Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.
Acknowledge receipt of a work item, transitioning it from 'queued' to 'starting' and removing it from the queue.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 182 def ack(work_id, params) parsed, = Anthropic::Beta::Environments::WorkAckParams.dump_request(params) environment_id = parsed.delete(:environment_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::ENVIRONMENTS_WORK_ACK, span_attributes: { "anthropic.environment.id" => environment_id, "anthropic.environment.work.id" => work_id }, span_route: "/v1/environments/{environment_id}/work/{work_id}/ack", method: :post, path: ["v1/environments/%1$s/work/%2$s/ack", environment_id, work_id], headers: parsed.transform_keys(betas: "anthropic-beta"), model: Anthropic::Beta::Environments::BetaSelfHostedWork, options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **} ) end |
#heartbeat(work_id, environment_id:, desired_ttl_seconds: nil, expected_last_heartbeat: nil, betas: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWorkHeartbeatResponse
Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.
Record a heartbeat for a work item to maintain the lease.
Some parameter documentations has been truncated, see Models::Beta::Environments::WorkHeartbeatParams for more details.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 233 def heartbeat(work_id, params) query_params = [:desired_ttl_seconds, :expected_last_heartbeat] parsed, = Anthropic::Beta::Environments::WorkHeartbeatParams.dump_request(params) query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params)) environment_id = parsed.delete(:environment_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::ENVIRONMENTS_WORK_HEARTBEAT, span_attributes: { "anthropic.environment.id" => environment_id, "anthropic.environment.work.id" => work_id }, span_route: "/v1/environments/{environment_id}/work/{work_id}/heartbeat", span_query: %w[desired_ttl_seconds expected_last_heartbeat], method: :post, path: ["v1/environments/%1$s/work/%2$s/heartbeat", environment_id, work_id], query: query, headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"), model: Anthropic::Beta::Environments::BetaSelfHostedWorkHeartbeatResponse, options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **} ) end |
#list(environment_id, limit: nil, page: nil, betas: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Beta::Environments::BetaSelfHostedWork>
List work items in an environment.
This endpoint accepts the environment key as a bearer token. It rejects a Claude API key. On Claude Platform on AWS or Claude Models on Google Cloud (Anthropic managed), use that platform's credentials instead.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 141 def list(environment_id, params = {}) query_params = [:limit, :page] parsed, = Anthropic::Beta::Environments::WorkListParams.dump_request(params) query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::ENVIRONMENTS_WORK_LIST, span_attributes: {"anthropic.environment.id" => environment_id}, span_route: "/v1/environments/{environment_id}/work", span_query: %w[limit page], method: :get, path: ["v1/environments/%1$s/work", environment_id], query: query, headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"), page: Anthropic::Internal::PageCursor, model: Anthropic::Beta::Environments::BetaSelfHostedWork, options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **} ) end |
#poll(environment_id, block_ms: nil, reclaim_older_than_ms: nil, betas: nil, anthropic_worker_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork?
Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.
Long poll for work items in the queue.
Some parameter documentations has been truncated, see Models::Beta::Environments::WorkPollParams for more details.
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 286 def poll(environment_id, params = {}) query_params = [:block_ms, :reclaim_older_than_ms] parsed, = Anthropic::Beta::Environments::WorkPollParams.dump_request(params) query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::ENVIRONMENTS_WORK_POLL, span_attributes: {"anthropic.environment.id" => environment_id}, span_route: "/v1/environments/{environment_id}/work/poll", span_query: %w[block_ms reclaim_older_than_ms], method: :get, path: ["v1/environments/%1$s/work/poll", environment_id], query: query, headers: parsed.except(*query_params).transform_keys( betas: "anthropic-beta", anthropic_worker_id: "anthropic-worker-id" ), model: Anthropic::Beta::Environments::BetaSelfHostedWork, options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **} ) end |
#retrieve(work_id, environment_id:, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork
Retrieve detailed information about a specific work item.
This endpoint accepts a Claude API key. It rejects the environment key and the
work item's secret. On
Claude Platform on AWS
or
Claude Models on Google Cloud (Anthropic managed),
use that platform's credentials instead.
Some parameter documentations has been truncated, see Models::Beta::Environments::WorkRetrieveParams for more details.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 38 def retrieve(work_id, params) parsed, = Anthropic::Beta::Environments::WorkRetrieveParams.dump_request(params) environment_id = parsed.delete(:environment_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::ENVIRONMENTS_WORK_RETRIEVE, span_attributes: { "anthropic.environment.id" => environment_id, "anthropic.environment.work.id" => work_id }, span_route: "/v1/environments/{environment_id}/work/{work_id}", method: :get, path: ["v1/environments/%1$s/work/%2$s", environment_id, work_id], headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"), model: Anthropic::Beta::Environments::BetaSelfHostedWork, options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **} ) end |
#stats(environment_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWorkQueueStats
Get statistics about the work queue for an environment.
Some parameter documentations has been truncated, see Models::Beta::Environments::WorkStatsParams for more details.
329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 329 def stats(environment_id, params = {}) parsed, = Anthropic::Beta::Environments::WorkStatsParams.dump_request(params) @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::ENVIRONMENTS_WORK_STATS, span_attributes: {"anthropic.environment.id" => environment_id}, span_route: "/v1/environments/{environment_id}/work/stats", method: :get, path: ["v1/environments/%1$s/work/stats", environment_id], headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"), model: Anthropic::Beta::Environments::BetaSelfHostedWorkQueueStats, options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **} ) end |
#stop(work_id, environment_id:, force: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork
Stop a work item, initiating graceful or forced shutdown.
Some parameter documentations has been truncated, see Models::Beta::Environments::WorkStopParams for more details.
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 369 def stop(work_id, params) parsed, = Anthropic::Beta::Environments::WorkStopParams.dump_request(params) environment_id = parsed.delete(:environment_id) do raise ArgumentError.new("missing required path argument #{_1}") end header_params = {betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"} @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::ENVIRONMENTS_WORK_STOP, span_attributes: { "anthropic.environment.id" => environment_id, "anthropic.environment.work.id" => work_id }, span_route: "/v1/environments/{environment_id}/work/{work_id}/stop", method: :post, path: ["v1/environments/%1$s/work/%2$s/stop", environment_id, work_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Anthropic::Beta::Environments::BetaSelfHostedWork, options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **} ) end |
#update(work_id, environment_id:, metadata:, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Environments::BetaSelfHostedWork
Update work item metadata with merge semantics.
This endpoint accepts a Claude API key. It rejects the environment key and the
work item's secret. On
Claude Platform on AWS
or
Claude Models on Google Cloud (Anthropic managed),
use that platform's credentials instead.
Some parameter documentations has been truncated, see Models::Beta::Environments::WorkUpdateParams for more details.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/anthropic/resources/beta/environments/work.rb', line 93 def update(work_id, params) parsed, = Anthropic::Beta::Environments::WorkUpdateParams.dump_request(params) environment_id = parsed.delete(:environment_id) do raise ArgumentError.new("missing required path argument #{_1}") end header_params = {betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"} @client.request( qualifiers: {beta: "true"}, span_name: Anthropic::Internal::Tracing::SpanName::ENVIRONMENTS_WORK_UPDATE, span_attributes: { "anthropic.environment.id" => environment_id, "anthropic.environment.work.id" => work_id }, span_route: "/v1/environments/{environment_id}/work/{work_id}", method: :post, path: ["v1/environments/%1$s/work/%2$s", environment_id, work_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Anthropic::Beta::Environments::BetaSelfHostedWork, options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **} ) end |