{"modulePath":"github.com/agentruntimecontrolprotocol/go-sdk","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package arcp\n\nPackage arcp implements the ARCP wire protocol: a transport-agnostic envelope for submitting, observing, and controlling long-running AI agent jobs.\n\nThe root package exposes the on-the-wire envelope, sentinel error values, identifier helpers, and protocol-version constants. Higher level code lives in the sibling packages:\n\n  - [github.com/agentruntimecontrolprotocol/go-sdk/transport](/github.com/agentruntimecontrolprotocol/go-sdk/transport) — pluggable bidirectional envelope channels (memory, WebSocket, stdio).\n  - [github.com/agentruntimecontrolprotocol/go-sdk/messages](/github.com/agentruntimecontrolprotocol/go-sdk/messages) — typed payload structs registered against the envelope.\n  - [github.com/agentruntimecontrolprotocol/go-sdk/client](/github.com/agentruntimecontrolprotocol/go-sdk/client) — a client that talks to a runtime.\n  - [github.com/agentruntimecontrolprotocol/go-sdk/server](/github.com/agentruntimecontrolprotocol/go-sdk/server) — a runtime that hosts agents.\n  - [github.com/agentruntimecontrolprotocol/go-sdk/auth](/github.com/agentruntimecontrolprotocol/go-sdk/auth) — bearer verifier interface.\n  - [github.com/agentruntimecontrolprotocol/go-sdk/middleware](/github.com/agentruntimecontrolprotocol/go-sdk/middleware) — host-adapter sub-packages for net/http, chi, and OTel.\n\nThe wire format is JSON; envelopes carry an [Envelope.Payload](#Envelope.Payload) as raw bytes so the read loop can hand off without parsing twice.\n\n## Constants\n\n```go\nconst ProtocolVersion = \"1.1\"\n```\nProtocolVersion is the literal value carried in every envelope's \"arcp\" field.\n\n```go\nconst SDKVersion = \"1.1.0\"\n```\nSDKVersion is the version of this Go SDK.\n\n## Variables\n\n```go\nvar (\n\tErrPermissionDenied         = \u0026Error{Code: CodePermissionDenied, Message: \"permission denied\", Retryable: false}\n\tErrLeaseSubsetViolation     = \u0026Error{Code: CodeLeaseSubsetViolation, Message: \"lease subset violation\", Retryable: false}\n\tErrJobNotFound              = \u0026Error{Code: CodeJobNotFound, Message: \"job not found\", Retryable: false}\n\tErrDuplicateKey             = \u0026Error{Code: CodeDuplicateKey, Message: \"duplicate idempotency key\", Retryable: false}\n\tErrAgentNotAvailable        = \u0026Error{Code: CodeAgentNotAvailable, Message: \"agent not available\", Retryable: false}\n\tErrAgentVersionNotAvailable = \u0026Error{Code: CodeAgentVersionNotAvailable, Message: \"agent version not available\", Retryable: false}\n\tErrCancelled                = \u0026Error{Code: CodeCancelled, Message: \"cancelled\", Retryable: false}\n\tErrTimeout                  = \u0026Error{Code: CodeTimeout, Message: \"timeout\", Retryable: false}\n\tErrResumeWindowExpired      = \u0026Error{Code: CodeResumeWindowExpired, Message: \"resume window expired\", Retryable: false}\n\tErrHeartbeatLost            = \u0026Error{Code: CodeHeartbeatLost, Message: \"heartbeat lost\", Retryable: true}\n\tErrLeaseExpired             = \u0026Error{Code: CodeLeaseExpired, Message: \"lease expired\", Retryable: false}\n\tErrBudgetExhausted          = \u0026Error{Code: CodeBudgetExhausted, Message: \"budget exhausted\", Retryable: false}\n\tErrInvalidRequest           = \u0026Error{Code: CodeInvalidRequest, Message: \"invalid request\", Retryable: false}\n\tErrUnauthenticated          = \u0026Error{Code: CodeUnauthenticated, Message: \"unauthenticated\", Retryable: false}\n\tErrInternalError            = \u0026Error{Code: CodeInternalError, Message: \"internal error\", Retryable: true}\n)\n```\nSentinel error values. Each maps to one ErrorCode. Use errors.Is against these to test for a particular code.\n\n```go\nvar Features = []string{\n\t\"heartbeat\",\n\t\"ack\",\n\t\"list_jobs\",\n\t\"subscribe\",\n\t\"agent_versions\",\n\t\"lease_expires_at\",\n\t\"cost.budget\",\n\t\"model.use\",\n\t\"provisioned_credentials\",\n\t\"progress\",\n\t\"result_chunk\",\n}\n```\nFeatures is the canonical list of negotiable feature flags advertised in session.hello and session.welcome capabilities.\n\n## Functions\n\n```go\nfunc HasFeature(features []string, name string) bool\n```\nHasFeature reports whether name appears in features.\n\n```go\nfunc IntersectFeatures(a, b []string) []string\n```\nIntersectFeatures returns the set of feature flags present in both a and b, in the order they appear in a. Used at handshake to compute the effective negotiated feature set.\n\n```go\nfunc IsRetryable(err error) bool\n```\nIsRetryable reports whether err is structurally marked retryable. Non-arcp errors are conservatively reported as retryable so generic transport-level failures do not become fatal.\n\n```go\nfunc MarshalPayload(payload any) (json.RawMessage, error)\n```\nMarshalPayload encodes any value to json.RawMessage. nil and already-raw values pass through.\n\n```go\nfunc NewCallID() string\n```\nNewCallID returns a ULID prefixed with \"c\\_\" for tool\\_call.call\\_id.\n\n```go\nfunc NewEnvelopeID() string\n```\nNewEnvelopeID returns a UUIDv7. UUIDv7 carries a millisecond timestamp prefix and is suitable for the envelope id field.\n\n```go\nfunc NewJobID() string\n```\nNewJobID returns a ULID prefixed with \"job\\_\".\n\n```go\nfunc NewPayloadForType(typ string) any\n```\nNewPayloadForType returns a zero value of the registered type for typ suitable for json.Unmarshal. It returns nil if typ is not registered.\n\n```go\nfunc NewPingNonce() string\n```\nNewPingNonce returns a ULID prefixed with \"p\\_\". The nonce is matched on session.pong; ULIDs are short and time-ordered.\n\n```go\nfunc NewResultID() string\n```\nNewResultID returns a ULID prefixed with \"res\\_\".\n\n```go\nfunc NewSessionID() string\n```\nNewSessionID returns a ULID prefixed with \"sess\\_\".\n\n```go\nfunc NewTraceID() string\n```\nNewTraceID returns a 32-character lowercase hex string suitable for the envelope trace\\_id field (matches W3C trace-context).\n\n```go\nfunc NewULID() string\n```\nNewULID returns a Crockford-base32 ULID with the current wall-clock timestamp. ULIDs sort lexicographically; we use them for session/job/result/nonce identifiers so log scans stay ordered.\n\n```go\nfunc RegisterMessageType(m MessageType)\n```\nRegisterMessageType associates the concrete struct behind m with its wire-type string. Each wire-type string may only be registered once; duplicate registration panics. Call from init() in messages/\\*.go.\n\n```go\nfunc RegisteredTypes() []string\n```\nRegisteredTypes returns the names of every registered MessageType, useful for diagnostics.\n\n## Types\n\n```go\ntype BudgetAmount struct {\n\tCurrency Currency\n\tValue    float64\n}\n```\nBudgetAmount is one entry in a cost.budget pattern list, of the form \"USD:5.00\".\n\n```go\nfunc ParseBudgetAmount(s string) (BudgetAmount, error)\n```\nParseBudgetAmount parses a cost.budget pattern entry per the spec grammar: amount ::= currency \":\" decimal. Negative values are rejected.\n\n```go\nfunc (b BudgetAmount) String() string\n```\nString returns the canonical \"CUR:value\" representation.\n\n```go\ntype Capability string\n```\nCapability is the lease namespace identifier. The constants below enumerate spec-reserved namespaces; vendors may add their own string-valued capabilities.\n\n```go\nconst (\n\tCapFSRead        Capability = \"fs.read\"\n\tCapFSWrite       Capability = \"fs.write\"\n\tCapNetFetch      Capability = \"net.fetch\"\n\tCapToolCall      Capability = \"tool.call\"\n\tCapAgentDelegate Capability = \"agent.delegate\"\n\tCapModelUse      Capability = \"model.use\"\n\tCapCostBudget    Capability = \"cost.budget\"\n)\n```\nReserved capability namespaces.\n\n```go\ntype Currency string\n```\nCurrency is an ISO 4217 currency code, or the protocol-reserved \"credits\" string, or a runtime-defined identifier.\n\n```go\ntype Envelope struct {\n\t// ARCP is the protocol version literal. Always \"1.1\" on the wire.\n\tARCP string `json:\"arcp\"`\n\t// ID is a unique message identifier (UUIDv7 recommended).\n\tID string `json:\"id\"`\n\t// Type is the wire-type token, for example \"job.submit\".\n\tType string `json:\"type\"`\n\t// SessionID identifies the owning session; empty on session.hello.\n\tSessionID string `json:\"session_id,omitempty\"`\n\t// JobID is set on job-scoped envelopes (job.*).\n\tJobID string `json:\"job_id,omitempty\"`\n\t// TraceID is a 32-hex-char W3C trace identifier when present.\n\tTraceID string `json:\"trace_id,omitempty\"`\n\t// EventSeq is the session-scoped monotonic sequence for\n\t// job.event / job.result / job.error. Zero on every other type.\n\tEventSeq uint64 `json:\"event_seq,omitempty\"`\n\t// Payload is the typed payload, kept raw so the dispatch loop can\n\t// hand it off to a registered MessageType without parsing twice.\n\tPayload json.RawMessage `json:\"payload,omitempty\"`\n\t// Extensions carries x-vendor.* namespaced opaque fields per the\n\t// spec extensions namespace.\n\tExtensions map[string]json.RawMessage `json:\"extensions,omitempty\"`\n}\n```\nEnvelope is the wire-level frame for every ARCP message. Field names map exactly onto the JSON object documented in the spec.\n\n```go\nfunc NewEnvelope(typ string, payload any) (Envelope, error)\n```\nNewEnvelope returns an Envelope with arcp/id pre-populated.\n\n```go\nfunc (e *Envelope) DecodePayload(v any) error\n```\nDecodePayload unmarshals e.Payload into v.\n\n```go\nfunc (e *Envelope) Validate() error\n```\nValidate reports a structured \\*Error if the envelope is missing fields the protocol mandates.\n\n```go\ntype Error struct {\n\tCode      ErrorCode      `json:\"code\"`\n\tMessage   string         `json:\"message\"`\n\tRetryable bool           `json:\"retryable\"`\n\tDetails   map[string]any `json:\"details,omitempty\"`\n\t// contains filtered or unexported fields\n}\n```\nError is the structured ARCP error. It carries a code, a human message, a retry hint, optional structured details, and an optional wrapped cause.\n\n```go\nfunc Newf(code ErrorCode, format string, args ...any) *Error\n```\nNewf constructs an \\*Error with code and a formatted message.\n\n```go\nfunc (e *Error) Error() string\n```\nError implements the error interface.\n\n```go\nfunc (e *Error) Is(target error) bool\n```\nIs matches by Code so wrapped errors satisfy errors.Is against sentinel values.\n\n```go\nfunc (e *Error) Unwrap() error\n```\nUnwrap returns the wrapped cause, if any.\n\n```go\nfunc (e *Error) WithCause(cause error) *Error\n```\nWithCause returns a copy of e wrapping cause.\n\n```go\nfunc (e *Error) WithDetails(details map[string]any) *Error\n```\nWithDetails returns a copy of e with details merged into Details.\n\n```go\nfunc (e *Error) WithMessage(msg string) *Error\n```\nWithMessage returns a copy of e with msg as the human message.\n\n```go\ntype ErrorCode string\n```\nErrorCode is the canonical string code for the protocol's error taxonomy. The fifteen codes below cover every spec-mandated rejection point.\n\n```go\nconst (\n\tCodePermissionDenied         ErrorCode = \"PERMISSION_DENIED\"\n\tCodeLeaseSubsetViolation     ErrorCode = \"LEASE_SUBSET_VIOLATION\"\n\tCodeJobNotFound              ErrorCode = \"JOB_NOT_FOUND\"\n\tCodeDuplicateKey             ErrorCode = \"DUPLICATE_KEY\"\n\tCodeAgentNotAvailable        ErrorCode = \"AGENT_NOT_AVAILABLE\"\n\tCodeAgentVersionNotAvailable ErrorCode = \"AGENT_VERSION_NOT_AVAILABLE\"\n\tCodeCancelled                ErrorCode = \"CANCELLED\"\n\tCodeTimeout                  ErrorCode = \"TIMEOUT\"\n\tCodeResumeWindowExpired      ErrorCode = \"RESUME_WINDOW_EXPIRED\"\n\tCodeHeartbeatLost            ErrorCode = \"HEARTBEAT_LOST\"\n\tCodeLeaseExpired             ErrorCode = \"LEASE_EXPIRED\"\n\tCodeBudgetExhausted          ErrorCode = \"BUDGET_EXHAUSTED\"\n\tCodeInvalidRequest           ErrorCode = \"INVALID_REQUEST\"\n\tCodeUnauthenticated          ErrorCode = \"UNAUTHENTICATED\"\n\tCodeInternalError            ErrorCode = \"INTERNAL_ERROR\"\n)\n```\nThe full set of canonical error codes.\n\n```go\nfunc Code(err error) ErrorCode\n```\nCode walks the error chain and returns the first matched ErrorCode. If no \\*Error is found, Code returns CodeInternalError.\n\n```go\ntype Lease map[Capability][]string\n```\nLease maps capability namespaces to pattern lists. The lease is immutable for a job's lifetime; budget counters are runtime state derived from the lease, not part of it.\n\n```go\nfunc (l Lease) Clone() Lease\n```\nClone returns a deep copy of l.\n\n```go\nfunc (l Lease) MarshalJSON() ([]byte, error)\n```\nMarshalJSON encodes l as a JSON object with string-typed keys.\n\n```go\nfunc (l *Lease) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON decodes a JSON object into l.\n\n```go\ntype MessageType interface {\n\tARCPType() string\n}\n```\nMessageType is implemented by every typed payload struct registered against the envelope dispatch table.\n\n","path":"github.com/agentruntimecontrolprotocol/go-sdk","name":"arcp","synopsis":"Package arcp implements the ARCP wire protocol: a transport-agnostic envelope for submitting, observing, and controlling long-running AI agent jobs.","isRedistributable":true}
