Claude Platform Docs

Trabalho

Obter item de trabalho
beta.environments.work.retrieve(work_id, **kwargs) -> BetaSelfHostedWork
GET/v1/environments/{environment_id}/work/{work_id}

Observação: esses endpoints são chamados automaticamente pelo worker de ambiente pré-construído fornecido nos SDKs e na CLI, para orquestrar sessões com ambientes sandbox auto-hospedados. Eles estão incluídos aqui como referência; você não precisa invocá-los diretamente.

Fazer polling por trabalho
beta.environments.work.poll(environment_id, **kwargs) -> BetaSelfHostedWork
GET/v1/environments/{environment_id}/work/poll

Observação: esses endpoints são chamados automaticamente pelo worker de ambiente pré-construído fornecido nos SDKs e na CLI, para orquestrar sessões com ambientes sandbox auto-hospedados. Eles estão incluídos aqui como referência; você não precisa invocá-los diretamente.

Confirmar recebimento de trabalho
beta.environments.work.ack(work_id, **kwargs) -> BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/ack

Observação: esses endpoints são chamados automaticamente pelo worker de ambiente pré-construído fornecido nos SDKs e na CLI, para orquestrar sessões com ambientes sandbox auto-hospedados. Eles estão incluídos aqui como referência; você não precisa invocá-los diretamente.

Registrar heartbeat
beta.environments.work.heartbeat(work_id, **kwargs) -> BetaSelfHostedWorkHeartbeatResponse
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat

Observação: esses endpoints são chamados automaticamente pelo worker de ambiente pré-construído fornecido nos SDKs e na CLI, para orquestrar sessões com ambientes sandbox auto-hospedados. Eles estão incluídos aqui como referência; você não precisa invocá-los diretamente.

Parar trabalho
beta.environments.work.stop(work_id, **kwargs) -> BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/stop

Observação: esses endpoints são chamados automaticamente pelo worker de ambiente pré-construído fornecido nos SDKs e na CLI, para orquestrar sessões com ambientes sandbox auto-hospedados. Eles estão incluídos aqui como referência; você não precisa invocá-los diretamente.

Listar itens de trabalho
beta.environments.work.list(environment_id, **kwargs) -> PageCursor<BetaSelfHostedWork>
GET/v1/environments/{environment_id}/work

Observação: esses endpoints são chamados automaticamente pelo worker de ambiente pré-construído fornecido nos SDKs e na CLI, para orquestrar sessões com ambientes sandbox auto-hospedados. Eles estão incluídos aqui como referência; você não precisa invocá-los diretamente.

Atualizar item de trabalho
beta.environments.work.update(work_id, **kwargs) -> BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}

Observação: esses endpoints são chamados automaticamente pelo worker de ambiente pré-construído fornecido nos SDKs e na CLI, para orquestrar sessões com ambientes sandbox auto-hospedados. Eles estão incluídos aqui como referência; você não precisa invocá-los diretamente.

Obter estatísticas da fila
beta.environments.work.stats(environment_id, **kwargs) -> BetaSelfHostedWorkQueueStats
GET/v1/environments/{environment_id}/work/stats

Obtenha estatísticas sobre a fila de trabalho de um ambiente.

Models
class BetaSelfHostedWork { type: :work, id, acknowledged_at, 10 more }

Work resource representing a unit of work in a self-hosted environment.

Work items are queued when sessions are created or when long-dormant sessions receive new messages. The environment worker polls for work to execute in a self-hosted sandbox.

class BetaSelfHostedWorkHeartbeatResponse { type: :work_heartbeat, last_heartbeat, lease_extended, 2 more }

Response after recording a heartbeat for a work item.

type: :work_heartbeat

The type of response

last_heartbeat: String

RFC 3339 timestamp of the actual heartbeat from DB

lease_extended: bool

Whether the heartbeat succeeded in extending the lease

state: :queued | :starting | :active | 2 more

Current state of the work item (active/stopping/stopped)

One of the following:
:queued
:starting
:active
:stopping
:stopped
ttl_seconds: Integer

Effective TTL applied to the lease

class BetaSelfHostedWorkListResponse { data, next_page }

Response when listing work items with cursor-based pagination.

class BetaSelfHostedWorkQueueStats { type: :work_queue_stats, depth, oldest_queued_at, 2 more }

Statistics about the work queue for an environment.

Uses Redis Stream consumer group metrics for O(1) queries.

type: :work_queue_stats

The type of object

depth: Integer

Number of work items waiting to be picked up (lag from consumer group)

oldest_queued_at: String

RFC 3339 timestamp of oldest item in the work stream (includes both queued and pending items), null if stream empty

pending: Integer

Number of work items being processed (polled but not acknowledged)

workers_polling: Integer

Number of workers that have polled for work in the last 30 seconds. Requires worker_id to be sent with poll requests.

class BetaSelfHostedWorkStopRequest { force }

Request to stop a work item.

force: bool

If true, immediately stop work without graceful shutdown

class BetaSelfHostedWorkUpdateRequest { metadata }

Request to update work item metadata.

metadata: Hash[Symbol, String]

Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve existing metadata.

class BetaSessionWorkData { type: :session, id }

Work data for session work items.

This resource type is used when work represents a session that needs to be executed in a self-hosted environment.

type: :session

Type of work data

id: String

Session identifier (e.g., 'session_...')