Claude Platform Docs

작업

작업 항목 조회
client.Beta.Environments.Work.Get(ctx, workID, params) (*BetaSelfHostedWork, error)
GET/v1/environments/{environment_id}/work/{work_id}

특정 작업 항목에 대한 자세한 정보를 조회합니다.

작업 폴링
client.Beta.Environments.Work.Poll(ctx, environmentID, params) (*BetaSelfHostedWork, error)
GET/v1/environments/{environment_id}/work/poll

참고: 이 엔드포인트는 자체 호스팅 샌드박스 환경에서 세션을 오케스트레이션하기 위해 SDK 및 CLI에서 제공하는 사전 빌드된 환경 워커에 의해 자동으로 호출됩니다. 참조용으로 여기에 포함되어 있으며, 직접 호출할 필요는 없습니다.

작업 확인
client.Beta.Environments.Work.Ack(ctx, workID, params) (*BetaSelfHostedWork, error)
POST/v1/environments/{environment_id}/work/{work_id}/ack

참고: 이러한 엔드포인트는 자체 호스팅 샌드박스 환경과의 세션을 오케스트레이션하기 위해 SDK 및 CLI에서 제공되는 사전 빌드된 환경 워커에 의해 자동으로 호출됩니다. 참조용으로 여기에 포함되어 있으며, 직접 호출할 필요는 없습니다.

하트비트 기록
client.Beta.Environments.Work.Heartbeat(ctx, workID, params) (*BetaSelfHostedWorkHeartbeatResponse, error)
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat

참고: 이러한 엔드포인트는 자체 호스팅 샌드박스 환경과의 세션을 오케스트레이션하기 위해 SDK 및 CLI에서 제공되는 사전 빌드된 환경 워커에 의해 자동으로 호출됩니다. 참조용으로 여기에 포함되어 있으며, 직접 호출할 필요는 없습니다.

작업 중지
client.Beta.Environments.Work.Stop(ctx, workID, params) (*BetaSelfHostedWork, error)
POST/v1/environments/{environment_id}/work/{work_id}/stop

작업 항목을 중지하여 정상 종료 또는 강제 종료를 시작합니다.

작업 항목 나열
client.Beta.Environments.Work.List(ctx, environmentID, params) (*PageCursor[BetaSelfHostedWork], error)
GET/v1/environments/{environment_id}/work

환경의 작업 항목을 나열합니다.

작업 항목 업데이트
client.Beta.Environments.Work.Update(ctx, workID, params) (*BetaSelfHostedWork, error)
POST/v1/environments/{environment_id}/work/{work_id}

병합 시맨틱으로 작업 항목 메타데이터를 업데이트합니다.

큐 통계 가져오기
client.Beta.Environments.Work.Stats(ctx, environmentID, query) (*BetaSelfHostedWorkQueueStats, error)
GET/v1/environments/{environment_id}/work/stats

환경의 작업 큐에 대한 통계를 가져옵니다.

Models
type BetaHeartbeatPreconditionFailedErrorDetails struct { CurrentState; ErrorCode }
CurrentState BetaWorkLeaseState

The lease as the server holds it.

LastHeartbeat string

RFC 3339 timestamp of the stored heartbeat, or null if there has been none

LeaseExtended bool

Always false: a refused heartbeat does not extend the lease

State BetaWorkLeaseStateState

Current state of the work item

One of the following:
const BetaWorkLeaseStateStateQueued BetaWorkLeaseStateState = "queued"
const BetaWorkLeaseStateStateStarting BetaWorkLeaseStateState = "starting"
const BetaWorkLeaseStateStateActive BetaWorkLeaseStateState = "active"
const BetaWorkLeaseStateStateStopping BetaWorkLeaseStateState = "stopping"
const BetaWorkLeaseStateStateStopped BetaWorkLeaseStateState = "stopped"
TTLSeconds int64

TTL of the lease

ErrorCode BetaHeartbeatPreconditionFailedErrorCode
type BetaSelfHostedWork struct { Type: "work"; ID; AcknowledgedAt; /* 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.

type BetaSelfHostedWorkHeartbeatResponse struct { Type: "work_heartbeat"; LastHeartbeat; LeaseExtended; /* 2 more */ }

Response after recording a heartbeat for a work item.

Type WorkHeartbeat

The type of response

defaultwork_heartbeat
LastHeartbeat string

RFC 3339 timestamp of the most recent heartbeat recorded for this work item, or an empty string if none has been recorded

LeaseExtended bool

Whether the heartbeat succeeded in extending the lease

State BetaSelfHostedWorkHeartbeatResponseState

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

One of the following:
const BetaSelfHostedWorkHeartbeatResponseStateQueued BetaSelfHostedWorkHeartbeatResponseState = "queued"
const BetaSelfHostedWorkHeartbeatResponseStateStarting BetaSelfHostedWorkHeartbeatResponseState = "starting"
const BetaSelfHostedWorkHeartbeatResponseStateActive BetaSelfHostedWorkHeartbeatResponseState = "active"
const BetaSelfHostedWorkHeartbeatResponseStateStopping BetaSelfHostedWorkHeartbeatResponseState = "stopping"
const BetaSelfHostedWorkHeartbeatResponseStateStopped BetaSelfHostedWorkHeartbeatResponseState = "stopped"
TTLSeconds int64

Effective TTL applied to the lease

type BetaSelfHostedWorkListResponse struct { Data; NextPage }

Response when listing work items with cursor-based pagination.

type BetaSelfHostedWorkQueueStats struct { Type: "work_queue_stats"; Depth; OldestQueuedAt; /* 2 more */ }

Statistics about the work queue for an environment.

Type WorkQueueStats

The type of object

defaultwork_queue_stats
Depth int64

Number of work items waiting to be picked up

OldestQueuedAt string

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

Pending int64

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

default0
WorkersPolling int64

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

type BetaSelfHostedWorkStopRequestParam struct { Force }

Request to stop a work item.

Force bool Optional

If true, immediately stop work without graceful shutdown

defaultfalse
type BetaSelfHostedWorkUpdateRequestParam struct { Metadata }

Request to update work item metadata.

Metadata map[string]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.

type BetaSessionWorkData struct { 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_...')

type BetaWorkLeaseState struct { LastHeartbeat; LeaseExtended; State; TTLSeconds }

A work item's lease as the server holds it.

LastHeartbeat string

RFC 3339 timestamp of the stored heartbeat, or null if there has been none

LeaseExtended bool

Always false: a refused heartbeat does not extend the lease

State BetaWorkLeaseStateState

Current state of the work item

One of the following:
const BetaWorkLeaseStateStateQueued BetaWorkLeaseStateState = "queued"
const BetaWorkLeaseStateStateStarting BetaWorkLeaseStateState = "starting"
const BetaWorkLeaseStateStateActive BetaWorkLeaseStateState = "active"
const BetaWorkLeaseStateStateStopping BetaWorkLeaseStateState = "stopping"
const BetaWorkLeaseStateStateStopped BetaWorkLeaseStateState = "stopped"
TTLSeconds int64

TTL of the lease

Errors
const ErrorCodeBetaHeartbeatPreconditionFailed ErrorCode = "heartbeat_precondition_failed"⁠HTTP status 412

expected_last_heartbeat does not match the stored heartbeat, so another worker may hold the lease.