{"modulePath":"github.com/flashcatcloud/flashduty-runner","version":"v0.0.27","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package protocol\n\nPackage protocol defines the WebSocket message protocol between Runner and Flashduty.\n\n## Constants\n\n```go\nconst (\n\tUpgradePhaseDownloading = \"downloading\"\n\tUpgradePhaseVerifying   = \"verifying\"\n\tUpgradePhaseSwapping    = \"swapping\"\n\tUpgradePhaseFailed      = \"failed\"\n)\n```\nUpgrade phase labels for the runner's own local logging (journald). They are not reported over the wire — the backend infers progress from the version the runner reports on its next heartbeat.\n\n## Types\n\n```go\ntype AuthErrorMeta struct {\n\tStatusCode          int    `json:\"status_code,omitempty\"`\n\tWWWAuthenticate     string `json:\"www_authenticate,omitempty\"`\n\tResourceMetadataURL string `json:\"resource_metadata_url,omitempty\"`\n}\n```\nAuthErrorMeta carries the 401 challenge details so fc-safari can initiate the per-user OAuth flow without re-parsing opaque error strings.\n\n```go\ntype BashArgs struct {\n\tCommand string            `json:\"command\"`\n\tWorkdir string            `json:\"workdir,omitempty\"`\n\tTimeout int               `json:\"timeout,omitempty\"` // seconds\n\tEnv     map[string]string `json:\"env,omitempty\"`\n\n\t// Credential carries per-invocation egress auth out-of-band of the bash\n\t// environment. Safari sends it only to broker-capable (Linux) runners; the\n\t// runner keeps it in memory and injects it via the broker, never into\n\t// cmd.Env. When set, FLASHDUTY_APP_KEY is absent from Env (see the design\n\t// doc's frozen wire contract).\n\tCredential *BashCredential `json:\"credential,omitempty\"`\n}\n```\nBashArgs are the arguments for bash operation.\n\nEnv carries per-call environment variables the caller wants merged on top of the runner process's own environment. Values may be secrets (auth tokens, per-tenant API keys), so the runner MUST NOT log them — only the keys are safe to surface. The bash command itself should reference these as \\`$VAR\\_NAME\\` so the secret expands inside the shell and never appears in transport-layer logs that mirror Command.\n\n```go\ntype BashCredential struct {\n\tKey     string `json:\"key\"`\n\tBaseURL string `json:\"base_url\"`\n}\n```\nBashCredential carries per-invocation egress auth out-of-band of the bash environment. Sent by Safari only to broker-capable runners; the runner keeps it in memory and injects it via the broker, never into cmd.Env.\n\n```go\ntype BashResult struct {\n\tStdout   string `json:\"stdout\"`\n\tStderr   string `json:\"stderr\"`\n\tExitCode int    `json:\"exit_code\"`\n\n\t// Per-stream truncation metadata. A stream is \"truncated\" when either\n\t// processLargeOutput trimmed it OR the underlying LimitedWriter hit its\n\t// hard cap mid-execution (the captured buffer carries an inline marker).\n\tTruncatedStdout bool   `json:\"truncated_stdout,omitempty\"`\n\tTruncatedStderr bool   `json:\"truncated_stderr,omitempty\"`\n\tStdoutFilePath  string `json:\"stdout_file_path,omitempty\"`\n\tStderrFilePath  string `json:\"stderr_file_path,omitempty\"`\n\tStdoutTotalSize int64  `json:\"stdout_total_size,omitempty\"`\n\tStderrTotalSize int64  `json:\"stderr_total_size,omitempty\"`\n\n\t// Legacy stdout-only mirrors. Kept so older safari clients that only\n\t// parse these still see truncation. New code should read the stream-\n\t// specific fields instead.\n\tTruncated bool   `json:\"truncated,omitempty\"`\n\tFilePath  string `json:\"file_path,omitempty\"`\n\tTotalSize int64  `json:\"total_size,omitempty\"`\n}\n```\nBashResult is the result of a bash operation.\n\nStdout and stderr are tracked independently — either stream may be truncated and spilled to a separate file. The legacy fields (\\`Truncated\\`, \\`FilePath\\`, \\`TotalSize\\`) mirror the stdout-side fields for backward compatibility with older safari builds; new callers should prefer the stream-specific fields.\n\n```go\ntype DeleteKnowledgeFilesArgs struct {\n\tRelPaths []string `json:\"rel_paths\"`\n}\n```\nDeleteKnowledgeFilesArgs are the arguments for delete\\_knowledge\\_files operation.\n\n```go\ntype DeleteKnowledgeFilesResult struct {\n\tSuccess bool `json:\"success\"`\n}\n```\nDeleteKnowledgeFilesResult is the result of a delete\\_knowledge\\_files operation.\n\n```go\ntype EnvironmentInfo struct {\n\tOS            string `json:\"os\"`                        // e.g., \"darwin\", \"linux\", \"windows\"\n\tOSVersion     string `json:\"os_version\"`                // e.g., \"24.6.0\" for macOS\n\tArch          string `json:\"arch\"`                      // e.g., \"amd64\", \"arm64\"\n\tHostname      string `json:\"hostname\"`                  // Machine hostname\n\tShell         string `json:\"shell\"`                     // Default shell, e.g., \"/bin/zsh\"\n\tHomeDir       string `json:\"home_dir\"`                  // User home directory\n\tWorkspaceRoot string `json:\"workspace_root\"`            // Configured workspace root\n\tUsername      string `json:\"username\"`                  // Current user\n\tNumCPU        int    `json:\"num_cpu\"`                   // Number of CPUs\n\tTotalMemoryMB int64  `json:\"total_memory_mb,omitempty\"` // Total memory in MB\n\tTimezone      string `json:\"timezone\"`                  // Timezone name, e.g., \"Asia/Shanghai\"\n\tUTCOffset     string `json:\"utc_offset\"`                // UTC offset, e.g., \"+08:00\"\n}\n```\nEnvironmentInfo contains detailed environment information for LLM context. This is similar to Cursor's system reminder format.\n\n```go\ntype GlobArgs struct {\n\tPattern string `json:\"pattern\"`\n\t// Path scopes the search to a directory. Absolute = real filesystem path;\n\t// relative = resolved against the workspace root. Empty = workspace root.\n\tPath string `json:\"path,omitempty\"`\n}\n```\nGlobArgs are the arguments for glob operation.\n\n```go\ntype GlobResult struct {\n\tMatches []string `json:\"matches\"`\n}\n```\nGlobResult is the result of a glob operation.\n\n```go\ntype GrepArgs struct {\n\tPattern string   `json:\"pattern\"`\n\tInclude []string `json:\"include,omitempty\"`\n\n\t// OutputMode controls the shape of the result: \"content\" (default — file:line:text rows),\n\t// \"files_with_matches\" (one path per match), or \"count\" (one path:count per file).\n\tOutputMode string `json:\"output_mode,omitempty\"`\n\t// ContextBefore (-B) and ContextAfter (-A) request N lines of context around each match.\n\t// Honored by ripgrep only when OutputMode is \"content\".\n\tContextBefore int `json:\"context_before,omitempty\"`\n\tContextAfter  int `json:\"context_after,omitempty\"`\n\t// HeadLimit caps the number of result rows returned (post-format). 0 = unlimited.\n\tHeadLimit int `json:\"head_limit,omitempty\"`\n\t// FileType maps to ripgrep's --type (e.g., \"go\", \"py\", \"js\"). Ignored by the Go fallback.\n\tFileType string `json:\"file_type,omitempty\"`\n\t// CaseSensitive overrides ripgrep's default --smart-case.\n\t// nil = smart-case; true = case-sensitive; false = case-insensitive.\n\tCaseSensitive *bool `json:\"case_sensitive,omitempty\"`\n\t// Path scopes the search to a file or directory (rg PATH). Absolute = real\n\t// filesystem path; relative = workspace root. Empty = workspace root.\n\tPath string `json:\"path,omitempty\"`\n\t// Multiline enables ripgrep's -U --multiline-dotall: patterns may span lines\n\t// and \".\" matches newlines. Ignored by the Go fallback (line-based).\n\tMultiline bool `json:\"multiline,omitempty\"`\n\t// Offset skips the first N result rows before HeadLimit is applied (result\n\t// pagination). Applied uniformly to both the ripgrep and Go paths.\n\tOffset int `json:\"offset,omitempty\"`\n}\n```\nGrepArgs are the arguments for grep operation.\n\n```go\ntype GrepMatch struct {\n\tPath       string `json:\"path\"`\n\tLineNumber int    `json:\"line_number\"`\n\tContent    string `json:\"content\"`\n}\n```\nGrepMatch is a single match in a grep result.\n\n```go\ntype GrepResult struct {\n\tMatches   []GrepMatch `json:\"matches\"`\n\tContent   string      `json:\"content\"`              // Formatted content (may be truncated)\n\tTruncated bool        `json:\"truncated,omitempty\"`  // Whether content was truncated\n\tFilePath  string      `json:\"file_path,omitempty\"`  // Path to full content if truncated\n\tTotalSize int64       `json:\"total_size,omitempty\"` // Original content size\n\t// RegexCompileError surfaces a non-fatal fallback path: the requested pattern failed\n\t// to compile as a Go regexp, so the Go fallback walked files matching it as a literal.\n\t// Empty when ripgrep handled the request or compilation succeeded.\n\tRegexCompileError string `json:\"regex_compile_error,omitempty\"`\n}\n```\nGrepResult is the result of a grep operation.\n\n```go\ntype HeartbeatMetrics struct {\n\tCPUPercent    float64 `json:\"cpu_percent,omitempty\"`\n\tMemoryPercent float64 `json:\"memory_percent,omitempty\"`\n\tDiskPercent   float64 `json:\"disk_percent,omitempty\"`\n}\n```\nHeartbeatMetrics contains system metrics.\n\n```go\ntype HeartbeatPayload struct {\n\tEnvironmentID string            `json:\"environment_id\"`\n\tName          string            `json:\"name\"`\n\tLabels        []string          `json:\"labels\"`\n\tVersion       string            `json:\"version\"`\n\tEnvironment   *EnvironmentInfo  `json:\"environment,omitempty\"`\n\tMetrics       *HeartbeatMetrics `json:\"metrics,omitempty\"`\n}\n```\nHeartbeatPayload is the payload for heartbeat messages.\n\n```go\ntype KnowledgeFile struct {\n\tRelPath    string `json:\"rel_path\"`\n\tChecksum   string `json:\"checksum\"`\n\tContentB64 string `json:\"content_b64\"`\n}\n```\nKnowledgeFile is a single file entry in a stage\\_knowledge\\_files request.\n\n```go\ntype KnowledgeFileStatus struct {\n\tRelPath string `json:\"rel_path\"`\n\tSuccess bool   `json:\"success\"`\n\tError   string `json:\"error,omitempty\"`\n}\n```\nKnowledgeFileStatus is the per-file result entry in the stage ack.\n\n```go\ntype KnowledgeManifestEntry struct {\n\tRelPath  string `json:\"rel_path\"`\n\tChecksum string `json:\"checksum\"`\n}\n```\nKnowledgeManifestEntry is one (rel\\_path, checksum) pair in a reconcile manifest. rel\\_path uses the same \\`knowledge/\\\u003cscope\u003e/\\\u003cleaf\u003e\\` shape as StageKnowledgeFiles so the runner-side validator is shared.\n\n```go\ntype ListArgs struct {\n\tPath      string   `json:\"path\"`\n\tRecursive bool     `json:\"recursive,omitempty\"`\n\tIgnore    []string `json:\"ignore,omitempty\"`\n}\n```\nListArgs are the arguments for list operation.\n\n```go\ntype ListEntry struct {\n\tPath  string `json:\"path\"`\n\tIsDir bool   `json:\"is_dir\"`\n\tSize  int64  `json:\"size\"`\n}\n```\nListEntry is a single entry in a list result.\n\n```go\ntype ListResult struct {\n\tEntries []ListEntry `json:\"entries\"`\n}\n```\nListResult is the result of a list operation.\n\n```go\ntype MCPCallArgs struct {\n\tServer   MCPServerConfig `json:\"server\"`\n\tToolName string          `json:\"tool_name\"`\n\tArgs     json.RawMessage `json:\"args\"`\n\tTimeout  int             `json:\"timeout,omitempty\"` // seconds\n}\n```\nMCPCallArgs are the arguments for mcp\\_call operation.\n\n```go\ntype MCPCallPayload struct {\n\tCallID    string          `json:\"call_id\"`\n\tServer    MCPServerConfig `json:\"server\"`\n\tToolName  string          `json:\"tool_name\"`\n\tArguments json.RawMessage `json:\"arguments\"`\n}\n```\nMCPCallPayload is the payload for MCP tool calls. Server configuration is passed from cloud (stored in database).\n\n```go\ntype MCPCallResult struct {\n\tContent   string `json:\"content\"`\n\tIsError   bool   `json:\"is_error,omitempty\"`   // Whether the tool returned an error\n\tTruncated bool   `json:\"truncated,omitempty\"`  // Whether content was truncated\n\tFilePath  string `json:\"file_path,omitempty\"`  // Path to full content if truncated\n\tTotalSize int64  `json:\"total_size,omitempty\"` // Original content size\n}\n```\nMCPCallResult is the result of an mcp\\_call operation.\n\n```go\ntype MCPListToolsArgs struct {\n\tServer MCPServerConfig `json:\"server\"`\n}\n```\nMCPListToolsArgs are the arguments for mcp\\_list\\_tools operation.\n\n```go\ntype MCPListToolsResult struct {\n\tTools []MCPToolInfo `json:\"tools\"`\n}\n```\nMCPListToolsResult is the result of an mcp\\_list\\_tools operation.\n\n```go\ntype MCPResultPayload struct {\n\tCallID  string          `json:\"call_id\"`\n\tSuccess bool            `json:\"success\"`\n\tResult  json.RawMessage `json:\"result,omitempty\"`\n\tError   string          `json:\"error,omitempty\"`\n\n\t// P1: structured auth-error metadata (additive; old senders omit).\n\tErrorType    string         `json:\"error_type,omitempty\"`    // \"auth_error\" | \"\"\n\tAuthMetadata *AuthErrorMeta `json:\"auth_metadata,omitempty\"` // non-nil iff ErrorType==\"auth_error\"\n}\n```\nMCPResultPayload is the payload for MCP call results.\n\n```go\ntype MCPServerConfig struct {\n\tName           string            `json:\"name\"`\n\tTransport      string            `json:\"transport\"` // stdio, streamable-http, sse (legacy alias for streamable-http)\n\tCommand        string            `json:\"command,omitempty\"`\n\tArgs           []string          `json:\"args,omitempty\"`\n\tEnv            map[string]string `json:\"env,omitempty\"`\n\tURL            string            `json:\"url,omitempty\"`\n\tHeaders        map[string]string `json:\"headers,omitempty\"`\n\tDynamicHeaders map[string]string `json:\"dynamic_headers,omitempty\"`\n}\n```\nMCPServerConfig is the MCP server configuration passed from cloud.\n\n```go\ntype MCPToolInfo struct {\n\tName        string `json:\"name\"`\n\tDescription string `json:\"description\"`\n\tInputSchema any    `json:\"input_schema,omitempty\"`\n}\n```\nMCPToolInfo represents metadata for an MCP tool.\n\n```go\ntype Message struct {\n\tID        string          `json:\"id\"`\n\tType      MessageType     `json:\"type\"`\n\tPayload   json.RawMessage `json:\"payload\"`\n\tTimestamp int64           `json:\"timestamp\"`\n}\n```\nMessage is the base WebSocket message structure.\n\n```go\nfunc NewMessage(msgType MessageType, payload any) (*Message, error)\n```\nNewMessage creates a new message with the given type and payload.\n\n```go\ntype MessageType string\n```\nMessageType defines the type of WebSocket message.\n\n```go\nconst (\n\t// Flashduty -\u003e Runner (initial)\n\tMessageTypeWelcome MessageType = \"welcome\"\n\n\t// Runner -\u003e Flashduty\n\tMessageTypeHeartbeat  MessageType = \"heartbeat\"\n\tMessageTypeTaskOutput MessageType = \"task.output\"\n\tMessageTypeTaskResult MessageType = \"task.result\"\n\tMessageTypeMCPResult  MessageType = \"mcp.result\"\n\n\t// Flashduty -\u003e Runner\n\tMessageTypeTaskRequest MessageType = \"task.request\"\n\tMessageTypeTaskCancel  MessageType = \"task.cancel\"\n\tMessageTypeMCPCall     MessageType = \"mcp.call\"\n\t// Shutdown is Safari telling the runner to drop everything and exit —\n\t// used when CloudManager tears down a cloud sandbox so the runner's\n\t// WebSocket closes immediately instead of waiting for the 5s force\n\t// unregister timeout.\n\tMessageTypeShutdown MessageType = \"shutdown\"\n\n\t// Flashduty -\u003e Runner. Advertises the target version in response to a\n\t// heartbeat; the runner self-decides whether to apply (it reports only its\n\t// own version back — there is no upgrade-status channel).\n\tMessageTypeUpgrade MessageType = \"upgrade\"\n)\n```\n\n```go\ntype PackFolderArgs struct {\n\tPath      string `json:\"path\"`       // absolute path inside workspace\n\tSkillRoot bool   `json:\"skill_root\"` // when true, also exclude evals/ at the root\n\tMaxBytes  int64  `json:\"max_bytes\"`  // 0 = no cap; \u003e0 = error if zip exceeds\n}\n```\nPackFolderArgs walks a directory inside the workspace and returns a zip archive of its contents. Used by Safari's sync\\_files(type=\"skill\") path so the agent never has to package skills by hand.\n\n```go\ntype PackFolderResult struct {\n\tZipB64    string `json:\"zip_b64\"` // base64-encoded zip bytes\n\tSizeBytes int64  `json:\"size_bytes\"`\n\tFileCount int    `json:\"file_count\"`\n}\n```\nPackFolderResult carries the produced archive back to Safari.\n\n```go\ntype ReadArgs struct {\n\tPath   string `json:\"path\"`\n\tOffset int64  `json:\"offset,omitempty\"`\n\tLimit  int64  `json:\"limit,omitempty\"`\n}\n```\nReadArgs are the arguments for read operation.\n\n```go\ntype ReadResult struct {\n\tContent   string `json:\"content\"` // base64 encoded\n\tTotalSize int64  `json:\"total_size\"`\n}\n```\nReadResult is the result of a read operation.\n\n```go\ntype ReconcileKnowledgeManifestArgs struct {\n\tFiles []KnowledgeManifestEntry `json:\"files\"`\n\t// StagedScopes are the scopes this manifest is authoritative for: files\n\t// inside them that the manifest doesn't list are orphans and are pruned.\n\tStagedScopes []string `json:\"staged_scopes,omitempty\"`\n\t// ValidScopes are ALL scopes that currently exist account-wide (a\n\t// superset of StagedScopes). On-disk scopes outside it are deleted-pack\n\t// residue and are pruned whole; scopes inside ValidScopes but outside\n\t// StagedScopes belong to other sessions and are left untouched.\n\t//\n\t// Empty ValidScopes means either an older Safari (no scope info) or an\n\t// account with zero packs; both fall back to the legacy global orphan\n\t// prune, which is correct in both cases.\n\tValidScopes []string `json:\"valid_scopes,omitempty\"`\n}\n```\nReconcileKnowledgeManifestArgs supplies the canonical view of which knowledge files should exist on disk and at what checksum. The runner deletes anything not in the manifest (orphan prune) and anything whose on-disk checksum disagrees (stale prune); the result's NeedsStage field tells the caller which manifest entries the runner does NOT have cached so the caller can bulk-stage them in one follow-up batch (skills-style eager materialization).\n\nThe two scope lists bound the orphan prune on runners shared by concurrent sessions. A manifest covers only the scopes its session staged (above Safari's full-staging cap that is a per-session subset), so without them a global prune would evict another session's validly mounted scopes — the two sessions would thrash each other's files. Scope segments use the on-disk directory names: \"account\" or \"team\\_\\\u003cid\u003e\".\n\n```go\ntype ReconcileKnowledgeManifestResult struct {\n\tPruned     []string `json:\"pruned,omitempty\"`\n\tKeptCount  int      `json:\"kept_count\"`\n\tStaleCount int      `json:\"stale_count\"`\n\tNeedsStage []string `json:\"needs_stage,omitempty\"`\n}\n```\nReconcileKnowledgeManifestResult reports the diff outcome plus the list of entries the caller still needs to push.\n\nPruned lists every rel\\_path the runner removed (orphans + stale together). StaleCount is the subset of Pruned whose rel\\_path was in the manifest but had a divergent checksum — useful for spotting upstream edits. KeptCount counts files left untouched because their checksum already matched. NeedsStage enumerates every manifest entry the runner does NOT have on disk after the prune step. The caller (Safari) materializes these by fetching from S3 and calling StageKnowledgeFiles. Empty when the runner is already in sync with the manifest.\n\n```go\ntype StageKnowledgeFilesArgs struct {\n\tFiles []KnowledgeFile `json:\"files\"`\n}\n```\nStageKnowledgeFilesArgs are the arguments for stage\\_knowledge\\_files operation.\n\n```go\ntype StageKnowledgeFilesResult struct {\n\tFiles []KnowledgeFileStatus `json:\"files\"`\n}\n```\nStageKnowledgeFilesResult is the result of a stage\\_knowledge\\_files operation.\n\n```go\ntype SyncSkillArgs struct {\n\tSkillName string `json:\"skill_name\"`\n\tSkillDir  string `json:\"skill_dir\"`\n\tZipData   string `json:\"zip_data\"` // base64 encoded zip\n\tChecksum  string `json:\"checksum\"`\n}\n```\nSyncSkillArgs are the arguments for sync\\_skill operation.\n\n```go\ntype SyncSkillResult struct {\n\tSuccess bool   `json:\"success\"`\n\tPath    string `json:\"path\"`             // Local path where skill is materialized\n\tCached  bool   `json:\"cached,omitempty\"` // True iff cache hit\n}\n```\nSyncSkillResult is the result of a sync\\_skill operation.\n\nProbe semantics: when SyncSkillArgs.ZipData is empty, the runner checks its local cache and returns either {Success:true, Cached:true, Path} on hit or {Success:true, Cached:false, Path:\"\"} on miss (cloud must retry with zip). When ZipData is non-empty, the runner installs unconditionally and returns {Success:true, Cached:false, Path}.\n\n```go\ntype TaskCancelPayload struct {\n\tTaskID string `json:\"task_id\"`\n}\n```\nTaskCancelPayload is the payload for task cancellation.\n\n```go\ntype TaskOperation string\n```\nTaskOperation defines the type of workspace operation.\n\n```go\nconst (\n\tTaskOpRead                       TaskOperation = \"read\"\n\tTaskOpWrite                      TaskOperation = \"write\"\n\tTaskOpList                       TaskOperation = \"list\"\n\tTaskOpGlob                       TaskOperation = \"glob\"\n\tTaskOpGrep                       TaskOperation = \"grep\"\n\tTaskOpBash                       TaskOperation = \"bash\"\n\tTaskOpWebFetch                   TaskOperation = \"webfetch\"\n\tTaskOpMCPCall                    TaskOperation = \"mcp_call\"\n\tTaskOpMCPListTools               TaskOperation = \"mcp_list_tools\"\n\tTaskOpSyncSkill                  TaskOperation = \"sync_skill\"\n\tTaskOpPackFolder                 TaskOperation = \"pack_folder\"\n\tTaskOpStageKnowledgeFiles        TaskOperation = \"stage_knowledge_files\"\n\tTaskOpDeleteKnowledgeFiles       TaskOperation = \"delete_knowledge_files\"\n\tTaskOpReconcileKnowledgeManifest TaskOperation = \"reconcile_knowledge_manifest\"\n)\n```\n\n```go\ntype TaskOutputPayload struct {\n\tTaskID string `json:\"task_id\"`\n\tStream string `json:\"stream\"` // stdout, stderr\n\tData   string `json:\"data\"`\n}\n```\nTaskOutputPayload is the payload for streaming task output.\n\n```go\ntype TaskRequestPayload struct {\n\tTaskID           string          `json:\"task_id\"`\n\tTraceID          string          `json:\"trace_id,omitempty\"`\n\tSourceInstanceID string          `json:\"source_instance_id,omitempty\"` // Safari instance ID\n\tOperation        TaskOperation   `json:\"operation\"`\n\tArgs             json.RawMessage `json:\"args\"`\n}\n```\nTaskRequestPayload is the payload for task request messages.\n\n```go\ntype TaskResultPayload struct {\n\tTaskID           string          `json:\"task_id\"`\n\tSourceInstanceID string          `json:\"source_instance_id,omitempty\"` // Safari instance ID\n\tSuccess          bool            `json:\"success\"`\n\tResult           json.RawMessage `json:\"result,omitempty\"`\n\tError            string          `json:\"error,omitempty\"`\n\tExitCode         int             `json:\"exit_code,omitempty\"`\n}\n```\nTaskResultPayload is the payload for task completion.\n\n```go\ntype UpgradePayload struct {\n\tTargetVersion string `json:\"target_version\"`\n\tDownloadURL   string `json:\"download_url\"`\n\tSHA256        string `json:\"sha256\"`\n}\n```\nUpgradePayload is sent by Flashduty to advertise the target version (with its download URL + checksum) in response to a heartbeat. The runner self-decides whether to apply it.\n\n```go\ntype WebFetchArgs struct {\n\tURL     string `json:\"url\"`\n\tFormat  string `json:\"format,omitempty\"`  // markdown, text, html (default: markdown)\n\tTimeout int    `json:\"timeout,omitempty\"` // seconds (default: 30, max: 120)\n}\n```\nWebFetchArgs are the arguments for webfetch operation.\n\n```go\ntype WebFetchResult struct {\n\tContent   string `json:\"content\"`\n\tURL       string `json:\"url\"`                  // Final URL after redirects\n\tTruncated bool   `json:\"truncated,omitempty\"`  // Whether content was truncated\n\tFilePath  string `json:\"file_path,omitempty\"`  // Path to full content if truncated\n\tTotalSize int64  `json:\"total_size,omitempty\"` // Original content size\n}\n```\nWebFetchResult is the result of a webfetch operation.\n\n```go\ntype WelcomePayload struct {\n\tEnvironmentID string   `json:\"environment_id\"`\n\tName          string   `json:\"name\"`\n\tLabels        []string `json:\"labels\"`\n}\n```\nWelcomePayload is the payload for the welcome message sent by server after connection. Contains environment info (name, labels) managed via Web UI.\n\n```go\ntype WriteArgs struct {\n\tPath    string `json:\"path\"`\n\tContent string `json:\"content\"` // base64 encoded\n}\n```\nWriteArgs are the arguments for write operation.\n\n","path":"github.com/flashcatcloud/flashduty-runner/protocol","name":"protocol","synopsis":"Package protocol defines the WebSocket message protocol between Runner and Flashduty.","isRedistributable":true}
