data(retryable、reason、capability など)を持つ JSON-RPC エラーで、接続は WebSocket のクローズコードで終わります。各 SDK はこれらを型付きエラーとして提供します。
bma-executor-sdk 1.12.2 とその契約(
contracts/bma/executor、プロトコル bma.executor.v1.1)から生成しています。インストール、認証情報、クイックスタートは bma-executor-sdk の概要、プロトコル自体は Executor Protocol を参照してください。RPC エラー
相手から返された JSON-RPC エラー、または特定のコードと data で応答するためにハンドラーが返すエラー。export class RpcError extends Error {
constructor(
static withReason(code: number, reason: string, message: string): RpcError
toJSON(): JsonRpcError
}
class RPCError(ExecutorError):
"""A JSON-RPC error. A handler that raises it keeps its code on the wire."""
def __init__(self, code: int, message: str, data: dict[str, Any] | None = None) -> None: ...
@classmethod
def with_reason(cls, code: int, reason: str, message: str) -> RPCError: ...
@property
def retryable(self) -> bool | None: ...
def to_wire(self) -> dict[str, Any]: ...
type RPCError struct {
Code int
Message string
Data *JSONRPCErrorData
}
クライアントのエラー
executor 側:未接続、停止済み、同じ ID の別の executor に置き換えられた(クローズコード 4004:停止し、再接続しないこと)、再接続の上限到達。export class NotConnectedError extends Error {
constructor(message = 'executor channel is not connected')
}
export class ClientStoppedError extends Error {
constructor()
}
export class RequestTimeoutError extends Error {
constructor(method: string)
}
class NotConnectedError(ExecutorError):
"""The channel is not connected (yet, or any more)."""
def __init__(self, message: str = "executor channel is not connected") -> None: ...
class ClientStoppedError(ExecutorError):
"""The client was stopped, or closed with a terminal close code."""
def __init__(self, message: str = "client stopped") -> None: ...
var (
// ErrNotConnected is returned when a call is attempted before the channel opens.
ErrNotConnected = errors.New("bmaexecutor: executor channel is not connected")
// ErrClientStopped is returned after Stop or a terminal close code.
ErrClientStopped = errors.New("bmaexecutor: client stopped")
// ErrReplaced is Err after the harness closed with 4004: a newer
// connection for this executor is authoritative and this one must stop.
ErrReplaced = errors.New("bmaexecutor: executor connection was replaced (4004)")
// errResumedFromSuspend ends a connection the host was suspended with.
errResumedFromSuspend = errors.New("bmaexecutor: host resumed from suspend")
// ErrReconnectExhausted is Err after a positive MaxReconnectAttempts
// failed; it wraps the last failure.
ErrReconnectExhausted = errors.New("bmaexecutor: executor reconnect attempts exhausted")
// ErrCredentialRejected is wrapped by the token request error when the
// token endpoint answers 401 or 403 (an invalid or revoked environment
// key or machine token). A reconnect does not retry it: the client ends
// with it as Err. A TokenSource may wrap it for the same effect.
ErrCredentialRejected = errors.New("bmaexecutor: executor credential rejected")
// ErrRegistrationRefused is Err after the platform refused the
// executor's registration maxRefusedRegistrations times in a row: the
// close 4002 "runtime registration refused" right after
// executor.register, or an executor.register error for the executor's
// capabilities. It is a configuration error (a machine-scoped executor
// must declare the process or agent capability) that reconnecting
// cannot fix. It wraps the last refusal.
ErrRegistrationRefused = errors.New("bmaexecutor: executor registration refused")
)
harness のエラー
harness 側:セッションが終了した、tool.result の前に executor が失われた(ツールの結果は不明)、または executor が session.assign を拒否した。
export class SessionEndedError extends Error {
constructor()
}
export class ToolOutcomeUnknownError extends Error {
constructor()
}
export class AssignRejectedError extends Error {
constructor()
}
class SessionEndedError(ExecutorError):
"""A request on a session that has ended."""
def __init__(self) -> None: ...
class ToolOutcomeUnknownError(ExecutorError):
"""The executor was lost (lease expiry, executor.close, session ended, or a"""
def __init__(self) -> None: ...
class AssignRejectedError(ExecutorError):
"""session.assign answered accepted=false."""
def __init__(self) -> None: ...
var (
// ErrSessionEnded is returned for requests on a session that has ended.
ErrSessionEnded = errors.New("bmaexecutor: session ended")
// ErrToolOutcomeUnknown means the executor was lost (lease expiry,
// executor.close, session ended, or a restarted executor that no longer
// reports the session) before a tool.result arrived. The tool may or may
// not have run; the caller decides whether a retry is safe.
ErrToolOutcomeUnknown = errors.New("bmaexecutor: tool outcome unknown: executor lost before tool.result")
// ErrAssignRejected is returned when session.assign answers accepted=false.
ErrAssignRejected = errors.New("bmaexecutor: executor rejected session.assign")
)
クローズコード
クライアントを完全に停止させるクローズコード。export function isTerminalCloseCode(code: number): boolean
# Python SDK 1.12.2 にはありません。
func CloseCode(err error) int
JSON-RPC エラーコード
| コード | メッセージ |
|---|---|
-32700 | parse_error |
-32600 | invalid_request |
-32601 | method_not_found |
-32602 | invalid_params |
-32603 | internal_error |
-32000 | unauthorized |
-32001 | forbidden |
-32002 | not_found |
-32003 | lease_expired |
-32004 | timeout |
-32005 | canceled |
-32006 | payload_too_large |
-32007 | session_not_active |
-32008 | mcp_unavailable |
-32009 | executor_busy |
-32010 | unsupported_protocol |
-32011 | resource_unavailable |
-32012 | capability_unavailable |
-32013 | conflict |
エラー data
| 名前 | 型 | 必須 | 説明 |
|---|---|---|---|
retryable | boolean | いいえ | 呼び出し側がバックオフ付きでリトライすべき容量またはタイムアウトの失敗。 |
detail | string | いいえ | |
capability | string | いいえ | -32012 で不足しているケイパビリティ(例:“tool:read”、“process.pty”)。 |
reason | string | いいえ | 機械可読な原因。harness がそのまま渡すオープンセットです(process.start:ツール結果の error_code とプロセス状態の reason、turn.start:session.error の code)。推奨値:workspace_unavailable、workspace_boundary、workspace_read_only、session_rejected、local_confirmation_denied、local_confirmation_expired、process.start の spawn_failed / process_id_spec_mismatch、executor.register の capability_missing、model_token.refresh の turn_inactive / forbidden / model_token_unavailable、tools_token.refresh の turn_inactive / forbidden / tools_token_unavailable(契約 1.4.0)。プラットフォームツール呼び出し(プラットフォームのツールエンドポイント、AsyncAPI x-bma-platform-tools の ToolErrorCode)のツール結果の error_code もオープンセットで、environment_unavailable、machine_starting、machine_rebuilding、permission_denied、approval_required、approval_invalid、in_progress、idempotency_key_reused も含みます(契約 1.4.0)。computer use の呼び出しでは、さらに desktop_busy(別のセッションのターンがマシンのデスクトップを占有している)と desktop_human_control(人がデスクトップの制御リースを保持している:computer_observe と computer_action はどちらも拒否され、何も実行されず、スクリーンショットも撮られません。制御が戻された後、呼び出し側は行動する前に再度観察します)も含まれます。受信側は、知らない値も受け入れなければなりません。 |
terminal_code | string | いいえ | terminal.* の呼び出しが失敗したときの bma.terminal.v1 エラーコード。 |
expected_sequence | integer | いいえ | エージェントの session.event の欠落(-32013):harness が次に期待するシーケンス。 |
クローズコード
| コード | 意味 |
|---|---|
4001 | トークンの期限切れ |
4003 | サポートされないプロトコル |
4004 | 置き換え |
4005 | drain 済み |