Documentation
¶
Overview ¶
Package protocol defines the wire format between the GSD Cloud daemon, the Fly.io relay, and the browser. See PROTOCOL.md for the authoritative specification; every change here must be mirrored in that file.
Index ¶
- Constants
- func TraceID(traceparent string) string
- func ValidateEnvelopeFrame(data []byte, limits EnvelopeLimits) error
- func ValidateRequestBinding(expected any, actual any) error
- func ValidateSessionBinding(expected any, actual any) error
- type AgentTerminalAttach
- type AgentTerminalPort
- type AgentTerminalReadiness
- type AgentTerminalSnapshotRequest
- type AgentTerminalStarted
- type AgentTerminalUpdated
- type Binding
- type BrowseDir
- type BrowseDirResult
- type BrowseEntry
- type CompactLifecycleStatus
- type CompactReason
- type CompactRequest
- type CompactStatus
- type ContextRef
- type ContextStats
- type ContextStatsRequest
- type Envelope
- type EnvelopeLimits
- type Heartbeat
- type Hello
- type HelloCapabilities
- type ListSkills
- type ListSkillsResult
- type LocalServerDetected
- type MachineStatus
- type MessageType
- type MkDir
- type MkDirResult
- type PermissionRequest
- type PermissionResponse
- type PreviewClose
- type PreviewHTTPRequest
- type PreviewHTTPResponseHead
- type PreviewOpen
- type PreviewOpenResult
- type PreviewStreamCancel
- type PreviewStreamChunk
- type PreviewWebSocketClose
- type PreviewWebSocketData
- type PreviewWebSocketOpen
- type PreviewWebSocketOpenResult
- type Question
- type QuestionOption
- type QuestionResponse
- type ReadFile
- type ReadFileResult
- type Skill
- type Stop
- type Stream
- type Task
- type TaskAttemptStatus
- type TaskCancelled
- type TaskComplete
- type TaskDeadlines
- type TaskError
- type TaskLifecycle
- type TaskLifecyclePhase
- type TaskStarted
- type TerminalClose
- type TerminalError
- type TerminalExit
- type TerminalInput
- type TerminalOpen
- type TerminalOpened
- type TerminalOutput
- type TerminalResize
- type TerminalSnapshot
- type TurnKind
- type Welcome
Constants ¶
const ( DefaultMaxFrameBytes = 1 << 20 DefaultMaxDepth = 32 DefaultMaxObjectFields = 256 DefaultMaxArrayItems = 4096 )
const ( MsgTypeTask = "task" MsgTypeTaskLifecycle = "taskLifecycle" MsgTypeStop = "stop" MsgTypePermissionResponse = "permissionResponse" MsgTypeQuestionResponse = "questionResponse" MsgTypeBrowseDir = "browseDir" MsgTypeReadFile = "readFile" MsgTypeMkDir = "mkDir" MsgTypeMkDirResult = "mkDirResult" MsgTypeListSkills = "listSkills" MsgTypeListSkillsResult = "listSkillsResult" MsgTypeCompactRequest MessageType = "compactRequest" MsgTypeContextStatsRequest MessageType = "contextStatsRequest" MsgTypeStream = "stream" MsgTypeTaskStarted = "taskStarted" MsgTypeTaskComplete = "taskComplete" MsgTypeTaskError = "taskError" MsgTypeTaskCancelled = "taskCancelled" MsgTypePermissionRequest = "permissionRequest" MsgTypeQuestion = "question" MsgTypeHeartbeat = "heartbeat" MsgTypeBrowseDirResult = "browseDirResult" MsgTypeReadFileResult = "readFileResult" MsgTypeContextStats MessageType = "contextStats" MsgTypeCompactStatus MessageType = "compactStatus" MsgTypeHello = "hello" MsgTypeWelcome = "welcome" MsgTypeMachineStatus = "machineStatus" MsgTypePreviewOpen = "previewOpen" MsgTypePreviewOpenResult = "previewOpenResult" MsgTypePreviewClose = "previewClose" MsgTypePreviewHTTPRequest = "previewHttpRequest" MsgTypePreviewHTTPResponseHead = "previewHttpResponseHead" MsgTypePreviewStreamChunk = "previewStreamChunk" MsgTypePreviewStreamCancel = "previewStreamCancel" MsgTypePreviewWebSocketOpen = "previewWebSocketOpen" MsgTypePreviewWebSocketOpenResult = "previewWebSocketOpenResult" MsgTypePreviewWebSocketData = "previewWebSocketData" MsgTypePreviewWebSocketClose = "previewWebSocketClose" MsgTypeLocalServerDetected = "localServerDetected" MsgTypeTerminalOpen = "terminalOpen" MsgTypeTerminalOpened = "terminalOpened" MsgTypeTerminalInput = "terminalInput" MsgTypeTerminalOutput = "terminalOutput" MsgTypeTerminalSnapshot = "terminalSnapshot" MsgTypeTerminalResize = "terminalResize" MsgTypeTerminalClose = "terminalClose" MsgTypeTerminalExit = "terminalExit" MsgTypeTerminalError = "terminalError" MsgTypeAgentTerminalStarted = "agentTerminalStarted" MsgTypeAgentTerminalUpdated = "agentTerminalUpdated" MsgTypeAgentTerminalAttach = "agentTerminalAttach" MsgTypeAgentTerminalSnapshotRequest = "agentTerminalSnapshotRequest" )
Message type constants.
Variables ¶
This section is empty.
Functions ¶
func TraceID ¶ added in v0.4.1
TraceID extracts the trace-id component from a W3C traceparent header. Returns "" if the traceparent is empty or malformed. Format: version-traceid-parentid-traceflags (e.g. "00-abc...def-012...789-01")
func ValidateEnvelopeFrame ¶ added in v0.21.0
func ValidateEnvelopeFrame(data []byte, limits EnvelopeLimits) error
ValidateEnvelopeFrame checks transport-level JSON bounds before a frame is unmarshaled into a concrete protocol payload.
func ValidateRequestBinding ¶ added in v0.21.0
ValidateRequestBinding verifies that an actual message is bound to the same request ID as the expected request message or binding.
func ValidateSessionBinding ¶ added in v0.21.0
ValidateSessionBinding verifies that an actual message is bound to the same session and channel identifiers as the expected message or binding.
Types ¶
type AgentTerminalAttach ¶ added in v0.29.1
type AgentTerminalPort ¶ added in v0.29.1
type AgentTerminalReadiness ¶ added in v0.29.1
type AgentTerminalSnapshotRequest ¶ added in v0.29.1
type AgentTerminalStarted ¶ added in v0.29.1
type AgentTerminalStarted struct {
Type string `json:"type"`
JobID string `json:"jobId"`
TerminalID string `json:"terminalId"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
TaskID string `json:"taskId,omitempty"`
ToolCallID string `json:"toolCallId,omitempty"`
ProjectID string `json:"projectId"`
CommandPreview string `json:"commandPreview"`
Title string `json:"title"`
CWD string `json:"cwd"`
Status string `json:"status"`
Readiness AgentTerminalReadiness `json:"readiness"`
Ports []AgentTerminalPort `json:"ports,omitempty"`
URLs []string `json:"urls,omitempty"`
Seq int64 `json:"seq,omitempty"`
StartedAt string `json:"startedAt"`
}
type AgentTerminalUpdated ¶ added in v0.29.1
type AgentTerminalUpdated struct {
Type string `json:"type"`
JobID string `json:"jobId"`
TerminalID string `json:"terminalId"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
Status string `json:"status"`
Readiness AgentTerminalReadiness `json:"readiness"`
Ports []AgentTerminalPort `json:"ports,omitempty"`
URLs []string `json:"urls,omitempty"`
Seq int64 `json:"seq,omitempty"`
UpdatedAt string `json:"updatedAt"`
}
type Binding ¶ added in v0.21.0
type Binding struct {
RequestID string
SessionID string
ChannelID string
MachineID string
PreviewID string
StreamID string
TerminalID string
TaskID string
}
Binding contains the protocol identifiers used to bind requests, sessions, channels, and transport streams.
func ExtractBinding ¶ added in v0.21.0
ExtractBinding returns common correlation identifiers from a protocol message payload or Envelope.
type BrowseDir ¶
type BrowseDir struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
ChannelID string `json:"channelId"`
MachineID string `json:"machineId"`
Path string `json:"path"`
Limit int `json:"limit,omitempty"`
Cursor string `json:"cursor,omitempty"`
}
BrowseDir lists directory contents on the daemon's machine.
type BrowseDirResult ¶
type BrowseDirResult struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
ChannelID string `json:"channelId"`
OK bool `json:"ok"`
Entries []BrowseEntry `json:"entries,omitempty"`
HasMore bool `json:"hasMore,omitempty"`
NextCursor string `json:"nextCursor,omitempty"`
Error string `json:"error,omitempty"`
}
BrowseDirResult is the daemon's response to a BrowseDir request.
type BrowseEntry ¶
type BrowseEntry struct {
Name string `json:"name"`
Path string `json:"path"`
IsDirectory bool `json:"isDirectory"`
Size int64 `json:"size"`
ModifiedAt string `json:"modifiedAt"`
}
BrowseEntry is one row in a directory listing.
type CompactLifecycleStatus ¶ added in v0.4.1
type CompactLifecycleStatus string
const ( CompactStatusStarted CompactLifecycleStatus = "started" CompactStatusCompleted CompactLifecycleStatus = "completed" CompactStatusFailed CompactLifecycleStatus = "failed" )
type CompactReason ¶ added in v0.4.1
type CompactReason string
const ( CompactReasonManual CompactReason = "manual" CompactReasonThreshold CompactReason = "threshold" CompactReasonOverflow CompactReason = "overflow" )
type CompactRequest ¶ added in v0.4.1
type CompactRequest struct {
Type MessageType `json:"type"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
RequestID string `json:"requestId"`
Instructions string `json:"instructions,omitempty"`
}
type CompactStatus ¶ added in v0.4.1
type CompactStatus struct {
Type MessageType `json:"type"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
RequestID string `json:"requestId"`
Status CompactLifecycleStatus `json:"status"`
Reason CompactReason `json:"reason"`
Instructions string `json:"instructions,omitempty"`
TokensBefore *int64 `json:"tokensBefore"`
TokensAfter *int64 `json:"tokensAfter"`
ContextWindow int64 `json:"contextWindow"`
ReserveTokens int64 `json:"reserveTokens"`
KeepRecentTokens int64 `json:"keepRecentTokens"`
AutoThresholdPercent float64 `json:"autoThresholdPercent"`
Summary string `json:"summary,omitempty"`
FirstKeptEntryID string `json:"firstKeptEntryId,omitempty"`
Error string `json:"error,omitempty"`
Source string `json:"source"`
ObservedAt time.Time `json:"observedAt"`
}
type ContextRef ¶ added in v0.19.1
type ContextStats ¶ added in v0.4.1
type ContextStats struct {
Type MessageType `json:"type"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
RequestID string `json:"requestId,omitempty"`
Tokens *int64 `json:"tokens"`
ContextWindow int64 `json:"contextWindow"`
Percent *float64 `json:"percent"`
ReserveTokens int64 `json:"reserveTokens"`
KeepRecentTokens int64 `json:"keepRecentTokens"`
AutoThresholdPercent float64 `json:"autoThresholdPercent"`
Source string `json:"source"`
ObservedAt time.Time `json:"observedAt"`
}
type ContextStatsRequest ¶ added in v0.4.1
type ContextStatsRequest struct {
Type MessageType `json:"type"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
RequestID string `json:"requestId"`
}
type Envelope ¶
Envelope is a parsed message ready for type-switching.
func ParseEnvelope ¶
ParseEnvelope reads raw JSON, looks at the type field, and unmarshals into the correct concrete struct.
func ParseEnvelopeWithLimits ¶ added in v0.21.0
func ParseEnvelopeWithLimits(data []byte, limits EnvelopeLimits) (*Envelope, error)
ParseEnvelopeWithLimits validates frame size, JSON nesting depth, object field counts, and array element counts before parsing the envelope.
func (Envelope) DecodePayload ¶ added in v0.32.0
type EnvelopeLimits ¶ added in v0.21.0
EnvelopeLimits bounds protocol frame parsing before payload unmarshalling. Zero values use the default limit for that field.
func DefaultEnvelopeLimits ¶ added in v0.21.0
func DefaultEnvelopeLimits() EnvelopeLimits
DefaultEnvelopeLimits returns the default frame parsing limits.
type Heartbeat ¶
type Heartbeat struct {
Type string `json:"type"`
MachineID string `json:"machineId"`
DaemonVersion string `json:"daemonVersion"`
Status string `json:"status"`
Timestamp string `json:"timestamp"`
}
Heartbeat is the daemon's 30s health pulse.
type Hello ¶
type Hello struct {
Type string `json:"type"`
MachineID string `json:"machineId"`
DaemonVersion string `json:"daemonVersion"`
OS string `json:"os"`
Arch string `json:"arch"`
ActiveTasks []string `json:"activeTasks,omitempty"`
Capabilities *HelloCapabilities `json:"capabilities,omitempty"`
}
Hello is the first frame sent by the daemon after connecting.
type HelloCapabilities ¶ added in v0.4.1
type HelloCapabilities struct {
Stop bool `json:"stop,omitempty"`
Terminal bool `json:"terminal,omitempty"`
AgentTerminalJobs bool `json:"agentTerminalJobs,omitempty"`
ContextRefs bool `json:"contextRefs,omitempty"`
PreviewTunnel bool `json:"previewTunnel,omitempty"`
PreviewMaxFrameBytes int `json:"previewMaxFrameBytes,omitempty"`
PreviewChunkBytes int `json:"previewChunkBytes,omitempty"`
PreviewWebSocketProtocols bool `json:"previewWebSocketProtocols,omitempty"`
LocalServerDetection bool `json:"localServerDetection,omitempty"`
Skills bool `json:"skills,omitempty"`
}
HelloCapabilities describes optional daemon protocol support.
type ListSkills ¶ added in v0.22.0
type ListSkills struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
ChannelID string `json:"channelId"`
MachineID string `json:"machineId"`
CWD string `json:"cwd"`
}
ListSkills asks the daemon to list available skills for a working directory.
type ListSkillsResult ¶ added in v0.22.0
type ListSkillsResult struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
ChannelID string `json:"channelId"`
OK bool `json:"ok"`
Skills []Skill `json:"skills,omitempty"`
Error string `json:"error,omitempty"`
}
ListSkillsResult is the daemon's response to a ListSkills request.
type LocalServerDetected ¶ added in v0.20.0
type LocalServerDetected struct {
Type string `json:"type"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
TaskID string `json:"taskId,omitempty"`
ToolUseID string `json:"toolUseId,omitempty"`
Host string `json:"host"`
Port int `json:"port"`
URL string `json:"url"`
Command string `json:"command,omitempty"`
Source string `json:"source"`
DetectedAt string `json:"detectedAt"`
}
type MachineStatus ¶ added in v0.4.1
type MachineStatus struct {
Type string `json:"type"`
MachineID string `json:"machineId"`
State string `json:"state"`
PreviousState string `json:"previousState,omitempty"`
Reason string `json:"reason,omitempty"`
OccurredAt string `json:"occurredAt"`
}
MachineStatus is pushed to all connected browsers when machine presence changes.
type MessageType ¶ added in v0.4.1
type MessageType = string
type MkDir ¶ added in v0.2.0
type MkDir struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
ChannelID string `json:"channelId"`
MachineID string `json:"machineId"`
Path string `json:"path"`
}
MkDir asks the daemon to create a directory.
type MkDirResult ¶ added in v0.2.0
type MkDirResult struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
ChannelID string `json:"channelId"`
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
}
MkDirResult is the daemon's response to a MkDir request.
type PermissionRequest ¶
type PermissionRequest struct {
Type string `json:"type"`
TaskID string `json:"taskId,omitempty"`
AttemptID string `json:"attemptId,omitempty"`
AttemptNumber int `json:"attemptNumber,omitempty"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
RequestID string `json:"requestId"`
ToolName string `json:"toolName"`
ToolInput json.RawMessage `json:"toolInput"`
}
PermissionRequest is Claude asking for tool approval.
type PermissionResponse ¶
type PermissionResponse struct {
Type string `json:"type"`
ChannelID string `json:"channelId"`
SessionID string `json:"sessionId"`
RequestID string `json:"requestId"`
Approved bool `json:"approved"`
}
PermissionResponse is the browser's answer to a permission request.
type PreviewClose ¶ added in v0.17.0
type PreviewHTTPRequest ¶ added in v0.17.0
type PreviewHTTPResponseHead ¶ added in v0.17.0
type PreviewOpen ¶ added in v0.17.0
type PreviewOpen struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
PreviewID string `json:"previewId"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
MachineID string `json:"machineId"`
TargetHost string `json:"targetHost"`
TargetPort int `json:"targetPort"`
ExpiresAt string `json:"expiresAt"`
}
type PreviewOpenResult ¶ added in v0.17.0
type PreviewStreamCancel ¶ added in v0.17.0
type PreviewStreamChunk ¶ added in v0.17.0
type PreviewWebSocketClose ¶ added in v0.17.0
type PreviewWebSocketData ¶ added in v0.17.0
type PreviewWebSocketOpen ¶ added in v0.17.0
type PreviewWebSocketOpenResult ¶ added in v0.17.0
type Question ¶
type Question struct {
Type string `json:"type"`
TaskID string `json:"taskId,omitempty"`
AttemptID string `json:"attemptId,omitempty"`
AttemptNumber int `json:"attemptNumber,omitempty"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
RequestID string `json:"requestId"`
Question string `json:"question"`
Header string `json:"header,omitempty"`
MultiSelect bool `json:"multiSelect,omitempty"`
Options []QuestionOption `json:"options,omitempty"`
}
Question is Claude asking the user for input.
type QuestionOption ¶ added in v0.4.1
type QuestionOption struct {
Label string `json:"label"`
Description string `json:"description,omitempty"`
Preview string `json:"preview,omitempty"`
}
QuestionOption is a structured answer choice for AskUserQuestion.
type QuestionResponse ¶
type QuestionResponse struct {
Type string `json:"type"`
ChannelID string `json:"channelId"`
SessionID string `json:"sessionId"`
RequestID string `json:"requestId"`
Answer string `json:"answer"`
}
QuestionResponse is the browser's answer to a question.
type ReadFile ¶
type ReadFile struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
ChannelID string `json:"channelId"`
MachineID string `json:"machineId"`
Path string `json:"path"`
MaxBytes int `json:"maxBytes,omitempty"`
}
ReadFile reads a file from the daemon's filesystem.
type ReadFileResult ¶
type ReadFileResult struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
ChannelID string `json:"channelId"`
OK bool `json:"ok"`
Content string `json:"content,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Error string `json:"error,omitempty"`
}
ReadFileResult is the daemon's response to a ReadFile request.
type Skill ¶ added in v0.22.0
type Skill struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Path string `json:"path"`
Scope string `json:"scope"`
}
Skill is a locally installed agent skill discovered on the daemon machine.
type Stop ¶
type Stop struct {
Type string `json:"type"`
ChannelID string `json:"channelId"`
SessionID string `json:"sessionId"`
}
Stop asks the daemon to interrupt the current Claude process for a session.
type Stream ¶
type Stream struct {
Type string `json:"type"`
TaskID string `json:"taskId,omitempty"`
AttemptID string `json:"attemptId,omitempty"`
AttemptNumber int `json:"attemptNumber,omitempty"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
SequenceNumber int64 `json:"sequenceNumber"`
Event json.RawMessage `json:"event"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"` // W3C trace context
}
Stream carries a single Claude event plus a sequence number.
type Task ¶
type Task struct {
Type string `json:"type"`
TaskID string `json:"taskId"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
AttemptID string `json:"attemptId,omitempty"`
AttemptNumber int `json:"attemptNumber,omitempty"`
LeaseExpiresAt string `json:"leaseExpiresAt,omitempty"`
DeadlineProfile TaskDeadlines `json:"deadlineProfile,omitempty"`
TurnKind TurnKind `json:"turnKind,omitempty"`
Prompt string `json:"prompt"`
Engine string `json:"engine,omitempty"` // "pi"; empty defaults to pi
Provider string `json:"provider,omitempty"` // Pi provider; empty defaults to claude-cli
Model string `json:"model"`
Effort string `json:"effort"`
PermissionMode string `json:"permissionMode"`
CWD string `json:"cwd"`
ClaudeSessionID string `json:"claudeSessionId,omitempty"` // passed to --resume
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"` // W3C trace context
ImageURLs []string `json:"imageUrls,omitempty"` // user-attached image URLs
ContextRefs []ContextRef `json:"contextRefs,omitempty"`
CustomInstructions string `json:"customInstructions,omitempty"`
DisableSkills bool `json:"disableSkills,omitempty"`
}
Task is sent from the browser to the daemon to dispatch a user message.
type TaskAttemptStatus ¶ added in v0.32.0
type TaskAttemptStatus string
const ( TaskAttemptStatusCreated TaskAttemptStatus = "created" TaskAttemptStatusQueued TaskAttemptStatus = "queued" TaskAttemptStatusStarted TaskAttemptStatus = "started" TaskAttemptStatusPiStarted TaskAttemptStatus = "pi_started" TaskAttemptStatusPromptWritten TaskAttemptStatus = "prompt_written" TaskAttemptStatusFirstEventSeen TaskAttemptStatus = "first_event_seen" TaskAttemptStatusFirstVisibleEventSeen TaskAttemptStatus = "first_visible_event_seen" TaskAttemptStatusStreaming TaskAttemptStatus = "streaming" TaskAttemptStatusWaitingInput TaskAttemptStatus = "waiting_input" TaskAttemptStatusToolRunning TaskAttemptStatus = "tool_running" TaskAttemptStatusCleanupStarted TaskAttemptStatus = "cleanup_started" TaskAttemptStatusCleanupFinished TaskAttemptStatus = "cleanup_finished" TaskAttemptStatusCompleted TaskAttemptStatus = "completed" TaskAttemptStatusFailed TaskAttemptStatus = "failed" TaskAttemptStatusCanceled TaskAttemptStatus = "canceled" TaskAttemptStatusTimedOut TaskAttemptStatus = "timed_out" TaskAttemptStatusLost TaskAttemptStatus = "lost" )
type TaskCancelled ¶ added in v0.4.0
type TaskCancelled struct {
Type string `json:"type"`
TaskID string `json:"taskId"`
AttemptID string `json:"attemptId,omitempty"`
AttemptNumber int `json:"attemptNumber,omitempty"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
FailureCode string `json:"failureCode,omitempty"`
Retryable bool `json:"retryable,omitempty"`
UserMessage string `json:"userMessage,omitempty"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"` // W3C trace context
}
TaskCancelled tells the relay/browser that a task was interrupted by the user.
type TaskComplete ¶
type TaskComplete struct {
Type string `json:"type"`
TaskID string `json:"taskId"`
AttemptID string `json:"attemptId,omitempty"`
AttemptNumber int `json:"attemptNumber,omitempty"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
ClaudeSessionID string `json:"claudeSessionId"`
InputTokens int64 `json:"inputTokens"`
OutputTokens int64 `json:"outputTokens"`
CostUSD string `json:"costUsd"`
DurationMs int `json:"durationMs"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"` // W3C trace context
}
TaskComplete reports final result metadata.
type TaskDeadlines ¶ added in v0.32.0
type TaskDeadlines struct {
ProcessStartMs int `json:"processStartMs,omitempty"`
PromptWriteMs int `json:"promptWriteMs,omitempty"`
FirstEventMs int `json:"firstEventMs,omitempty"`
FirstVisibleEventMs int `json:"firstVisibleEventMs,omitempty"`
StreamIdleMs int `json:"streamIdleMs,omitempty"`
ToolIdleMs int `json:"toolIdleMs,omitempty"`
UserInputMs int `json:"userInputMs,omitempty"`
CleanupTermMs int `json:"cleanupTermMs,omitempty"`
}
type TaskError ¶
type TaskError struct {
Type string `json:"type"`
TaskID string `json:"taskId"`
AttemptID string `json:"attemptId,omitempty"`
AttemptNumber int `json:"attemptNumber,omitempty"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
Error string `json:"error"`
FailureCode string `json:"failureCode,omitempty"`
Retryable bool `json:"retryable,omitempty"`
UserMessage string `json:"userMessage,omitempty"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"` // W3C trace context
}
TaskError reports a failure.
type TaskLifecycle ¶ added in v0.32.0
type TaskLifecycle struct {
Type MessageType `json:"type"`
TaskID string `json:"taskId"`
AttemptID string `json:"attemptId"`
AttemptNumber int `json:"attemptNumber"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
Phase TaskLifecyclePhase `json:"phase"`
Status TaskAttemptStatus `json:"status"`
Retryable bool `json:"retryable,omitempty"`
FailureCode string `json:"failureCode,omitempty"`
Message string `json:"message,omitempty"`
UserMessage string `json:"userMessage,omitempty"`
ObservedAt time.Time `json:"observedAt"`
DeadlineAt *time.Time `json:"deadlineAt,omitempty"`
PID int `json:"pid,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"`
}
type TaskLifecyclePhase ¶ added in v0.32.0
type TaskLifecyclePhase string
const ( TaskLifecyclePhaseAccepted TaskLifecyclePhase = "accepted" TaskLifecyclePhaseQueued TaskLifecyclePhase = "queued" TaskLifecyclePhaseStarted TaskLifecyclePhase = "started" TaskLifecyclePhasePiStarted TaskLifecyclePhase = "pi_started" TaskLifecyclePhasePromptWritten TaskLifecyclePhase = "prompt_written" TaskLifecyclePhaseFirstEventSeen TaskLifecyclePhase = "first_event_seen" TaskLifecyclePhaseFirstVisibleEventSeen TaskLifecyclePhase = "first_visible_event_seen" TaskLifecyclePhaseStreaming TaskLifecyclePhase = "streaming" TaskLifecyclePhaseToolStarted TaskLifecyclePhase = "tool_started" TaskLifecyclePhaseToolFinished TaskLifecyclePhase = "tool_finished" TaskLifecyclePhaseWaitingInput TaskLifecyclePhase = "waiting_input" TaskLifecyclePhaseInputReceived TaskLifecyclePhase = "input_received" TaskLifecyclePhaseCleanupStarted TaskLifecyclePhase = "cleanup_started" TaskLifecyclePhaseCleanupFinished TaskLifecyclePhase = "cleanup_finished" TaskLifecyclePhaseHeartbeat TaskLifecyclePhase = "heartbeat" TaskLifecyclePhaseRetryScheduled TaskLifecyclePhase = "retry_scheduled" TaskLifecyclePhaseCompleted TaskLifecyclePhase = "completed" TaskLifecyclePhaseFailed TaskLifecyclePhase = "failed" TaskLifecyclePhaseCanceled TaskLifecyclePhase = "canceled" TaskLifecyclePhaseTimedOut TaskLifecyclePhase = "timed_out" TaskLifecyclePhaseLost TaskLifecyclePhase = "lost" )
type TaskStarted ¶
type TaskStarted struct {
Type string `json:"type"`
TaskID string `json:"taskId"`
AttemptID string `json:"attemptId,omitempty"`
AttemptNumber int `json:"attemptNumber,omitempty"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
StartedAt string `json:"startedAt"`
RequestID string `json:"requestId,omitempty"`
Traceparent string `json:"traceparent,omitempty"` // W3C trace context
}
TaskStarted signals the daemon began processing a task.
type TerminalClose ¶ added in v0.18.0
type TerminalClose struct {
Type string `json:"type"`
TerminalID string `json:"terminalId"`
ChannelID string `json:"channelId"`
}
TerminalClose terminates the PTY.
type TerminalError ¶ added in v0.18.0
type TerminalError struct {
Type string `json:"type"`
RequestID string `json:"requestId,omitempty"`
TerminalID string `json:"terminalId,omitempty"`
SessionID string `json:"sessionId,omitempty"`
ChannelID string `json:"channelId"`
Error string `json:"error"`
}
TerminalError reports a terminal lifecycle or authorization error.
type TerminalExit ¶ added in v0.18.0
type TerminalExit struct {
Type string `json:"type"`
TerminalID string `json:"terminalId"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
ExitCode *int `json:"exitCode,omitempty"`
Signal string `json:"signal,omitempty"`
Reason string `json:"reason"`
EndedAt string `json:"endedAt"`
}
TerminalExit reports terminal process completion.
type TerminalInput ¶ added in v0.18.0
type TerminalInput struct {
Type string `json:"type"`
TerminalID string `json:"terminalId"`
ChannelID string `json:"channelId"`
DataBase64 string `json:"dataBase64"`
}
TerminalInput carries browser input bytes as base64.
type TerminalOpen ¶ added in v0.18.0
type TerminalOpen struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
TerminalID string `json:"terminalId,omitempty"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
Token string `json:"token,omitempty"`
CWD string `json:"cwd,omitempty"`
Cols int `json:"cols"`
Rows int `json:"rows"`
IdleTimeoutMs int `json:"idleTimeoutMs,omitempty"`
MaxLifetimeMs int `json:"maxLifetimeMs,omitempty"`
}
TerminalOpen requests a chat-scoped PTY terminal.
type TerminalOpened ¶ added in v0.18.0
type TerminalOpened struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
TerminalID string `json:"terminalId"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
Shell string `json:"shell"`
CWD string `json:"cwd"`
StartedAt string `json:"startedAt"`
}
TerminalOpened confirms a terminal has started.
type TerminalOutput ¶ added in v0.18.0
type TerminalOutput struct {
Type string `json:"type"`
TerminalID string `json:"terminalId"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
Seq int64 `json:"seq"`
DataBase64 string `json:"dataBase64"`
}
TerminalOutput carries terminal output bytes as base64.
type TerminalResize ¶ added in v0.18.0
type TerminalResize struct {
Type string `json:"type"`
TerminalID string `json:"terminalId"`
ChannelID string `json:"channelId"`
Cols int `json:"cols"`
Rows int `json:"rows"`
}
TerminalResize resizes the PTY.
type TerminalSnapshot ¶ added in v0.18.0
type TerminalSnapshot struct {
Type string `json:"type"`
TerminalID string `json:"terminalId"`
SessionID string `json:"sessionId"`
ChannelID string `json:"channelId"`
Seq int64 `json:"seq"`
DataBase64 string `json:"dataBase64"`
}
TerminalSnapshot carries bounded scrollback bytes as base64.