package protocol import "git.a-wan.net/alan/pipelines/internal/buildinfo" const ( Ping = "ping" Pong = "pong" Error = "error" Submit = "submit" Submitted = "submitted" List = "list_pipelines" PipelineList = "pipelines" GetPipeline = "get_pipeline" Pipeline = "pipeline" ListTemplates = "list_templates" Templates = "templates" Validate = "validate" Validated = "validated" // Archive and unarchive name the pipeline by PipelineID or Name; an // optional ExpectedVersion guards against a concurrent publication. Both // reply with the pipeline detail (ArchivedAt set while archived). ArchivePipeline = "archive_pipeline" PipelineArchived = "pipeline_archived" UnarchivePipeline = "unarchive_pipeline" PipelineUnarchived = "pipeline_unarchived" ) type Stage struct { Limits *StageLimits `json:"limits,omitempty"` Memory map[string]string `json:"memory,omitempty"` Notify *NotificationPolicy `json:"notify,omitempty"` Key string `json:"key"` Type string `json:"type,omitempty"` Output string `json:"output"` Prompt string `json:"prompt"` Configs map[string]string `json:"configs"` Edges map[string]string `json:"edges"` FallbackError bool `json:"fallback_error"` // Additional type-specific Markdown blocks; legacy model fields remain above. Blocks map[string]string `json:"blocks,omitempty"` } // Limits are enforced by the runner and never included in the model prompt. type StageLimits struct { MaxVisits int `json:"max_visits"` On []string `json:"on,omitempty"` } type NotificationPolicy struct { On []string `json:"on"` Destination string `json:"destination"` Artifacts []string `json:"artifacts,omitempty"` } // Public phone setup only. Never include publishing endpoints or credentials. type NotificationEndpoint struct { Destination string `json:"destination"` ServerURL string `json:"server_url,omitempty"` Topic string `json:"topic"` } type Template struct { Key string `json:"key"` Name string `json:"name"` Description string `json:"description"` Source string `json:"source"` Scheduled bool `json:"scheduled"` } type Graph struct { Stages []Stage `json:"stages"` Settings *Settings `json:"settings,omitempty"` } type Settings struct { Prompt string `json:"prompt"` Schedules []Schedule `json:"schedules"` } type Schedule struct { Days []string `json:"days,omitempty"` Times []string `json:"times,omitempty"` Every string `json:"every,omitempty"` Timezone string `json:"timezone,omitempty"` } type VersionSummary struct { Version int `json:"version"` Stages int `json:"stages"` CreatedAt string `json:"created_at"` } type PipelineDetail struct { PipelineSummary LatestVersion int `json:"latest_version"` VersionCreatedAt string `json:"version_created_at"` ContentHash string `json:"content_hash"` Source string `json:"source"` Graph Graph `json:"graph"` Versions []VersionSummary `json:"versions"` } type PipelineSummary struct { Scheduled bool `json:"scheduled"` ScheduleCount int `json:"schedule_count"` EnabledScheduleCount int `json:"enabled_schedule_count"` ID int64 `json:"id"` Name string `json:"name"` Version int `json:"version"` Stages int `json:"stages"` CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` // ArchivedAt is set (RFC 3339) while the pipeline is archived: it is // hidden from list_pipelines unless include_archived is set, cannot start // runs and keeps its name reserved. History is untouched. ArchivedAt string `json:"archived_at,omitempty"` // Shape is the current version's parsed graph, included so a list can draw // a miniature without one detail request per row. Detail responses keep the // full Graph field; this one is deliberately optional and additive. Shape *Graph `json:"shape,omitempty"` } // Message is the JSON envelope shared by the server and client. It also brokers // omni search: a client sends Type "search" with an ID, Query text, an optional // Kind type filter and an optional Limit, and the server replies with Type // "search_results", the echoed ID and a ranked SearchResponse. Both search fields // are optional so older peers ignore them. See search.go for the per-type payloads // and the ranking/kind/bound vocabulary. type Message struct { Storage *StorageOverview `json:"storage,omitempty"` StoragePolicy *StoragePolicy `json:"storage_policy,omitempty"` StorageCleanup *StorageCleanupResult `json:"storage_cleanup,omitempty"` StorageCleanupToken string `json:"storage_cleanup_token,omitempty"` Schedule *SavedSchedule `json:"schedule,omitempty"` Schedules []SavedSchedule `json:"schedules,omitempty"` ScheduleID int64 `json:"schedule_id,omitempty"` ExpectedRevision int64 `json:"expected_revision,omitempty"` DefaultHarness string `json:"default_harness,omitempty"` Build *buildinfo.Info `json:"build,omitempty"` Protocol int `json:"protocol,omitempty"` DefaultModel string `json:"default_model,omitempty"` Evidence []SessionEvidence `json:"evidence,omitempty"` Usage *UsageStats `json:"usage,omitempty"` Status *SystemStatus `json:"status,omitempty"` Graph *Graph `json:"graph,omitempty"` ExpectedVersion int `json:"expected_version,omitempty"` Templates []Template `json:"templates,omitempty"` CreateOnly bool `json:"create_only,omitempty"` IncludeArchived bool `json:"include_archived,omitempty"` NotificationEndpoints []NotificationEndpoint `json:"notification_endpoints,omitempty"` Type string `json:"type"` ID string `json:"id,omitempty"` Time string `json:"time,omitempty"` Error string `json:"error,omitempty"` Warnings []string `json:"warnings,omitempty"` // non-blocking authoring lint for validate/submit Name string `json:"name,omitempty"` Source string `json:"source,omitempty"` Title string `json:"title,omitempty"` Version int `json:"version,omitempty"` Pipelines []PipelineSummary `json:"pipelines,omitempty"` PipelineID int64 `json:"pipeline_id,omitempty"` Detail *PipelineDetail `json:"detail,omitempty"` RunID int64 `json:"run_id,omitempty"` RunDetail *RunDetail `json:"run_detail,omitempty"` Runs []RunSummary `json:"runs,omitempty"` Stage string `json:"stage,omitempty"` Option string `json:"option,omitempty"` Feedback string `json:"feedback,omitempty"` Input map[string]any `json:"input,omitempty"` AllowTools bool `json:"allow_tools,omitempty"` WritePaths []string `json:"write_paths,omitempty"` RequestKey string `json:"request_key,omitempty"` Workspace string `json:"workspace,omitempty"` // Model and StageModels are the launch-time model overrides: Model applies to // every model stage of the run and StageModels overrides individual stages by // key (per-stage wins over whole-run). Both are optional so older peers ignore // them; the same fields are echoed on the run record. Model string `json:"model,omitempty"` StageModels map[string]string `json:"stage_models,omitempty"` // OutputFormat is an optional per-run runtime report contract, never a // pipeline definition or model-stage prompt change. OutputFormat string `json:"output_format,omitempty"` // ExportSequence identifies the exact recorded visit for repair_session_export. ExportSequence int `json:"export_sequence,omitempty"` // NotifyMode is auto (definition), on (terminal success/failure and attention) or off // (silence this run). It is optional so older clients keep auto. NotifyMode string `json:"notify_mode,omitempty"` // Empty (or "resume") retries the failed visit; "restart" starts at the // entry stage. Older clients omit this field and retain resume behavior. RetryMode string `json:"retry_mode,omitempty"` RetrySource int64 `json:"-"` RetryStage string `json:"retry_stage,omitempty"` RetryVisit int `json:"retry_visit,omitempty"` RetryVersion int `json:"retry_version,omitempty"` RetryInput map[string]any `json:"retry_input,omitempty"` // Search is the broad, read-only search traffic over pipelines, versions, // runs, steps, field text and artifacts. See search.go for the per-type // payloads and the ranking/kind/bound vocabulary. Search *SearchRequest `json:"search,omitempty"` SearchResults *SearchResponse `json:"search_results,omitempty"` // Chat is the brokered OpenCode chat traffic (route B). See chat.go for the // per-type payload structs and the wire shapes they mirror. ChatSessions []ChatSession `json:"chat_sessions,omitempty"` ChatSession *ChatSession `json:"chat_session,omitempty"` ChatCreate *ChatCreateRequest `json:"chat_create,omitempty"` ChatAdopt *ChatAdoptRequest `json:"chat_adopt,omitempty"` ChatQuery *ChatQuery `json:"chat_query,omitempty"` ChatPrompt *ChatPromptRequest `json:"chat_prompt,omitempty"` ChatMessages []ChatMessage `json:"chat_messages,omitempty"` ChatHistory *ChatHistoryPage `json:"chat_history,omitempty"` ChatEvent *ChatEventFrame `json:"chat_event,omitempty"` ChatPermission *ChatPermissionFrame `json:"chat_permission,omitempty"` ChatReply *ChatReplyRequest `json:"chat_reply,omitempty"` // ChatClose carries the outcome of a chat_close; the close and reopen // requests themselves ride on ChatQuery (the session id), matching // chat_messages/chat_interrupt. ChatClose *ChatCloseResult `json:"chat_close,omitempty"` // ChatActivity is the chat_activity push: one session's live activity. ChatActivity *ChatActivity `json:"chat_activity,omitempty"` // ChatAnswer is the chat_answer body; the form update arrives through the // normal chat_event stream. ChatAnswer *ChatAnswerRequest `json:"chat_answer,omitempty"` // ChatRename is the chat_rename body; the reply echoes the updated session. ChatRename *ChatRenameRequest `json:"chat_rename,omitempty"` // ChatNewSession is the chat_new_session body; the reply carries the // re-keyed session in ChatSession with PreviousID set. ChatNewSession *ChatNewSessionRequest `json:"chat_new_session,omitempty"` // ChatExport is the chat_export body and ChatExportFile its reply. ChatExport *ChatExportRequest `json:"chat_export,omitempty"` ChatExportFile *ChatExportFile `json:"chat_export_file,omitempty"` // ChatBackends is the chat_backends reply: the installed harnesses a new // chat can use. ChatBackends []string `json:"chat_backends,omitempty"` // ChatModels is the chat_models reply: models the session's harness offers. ChatModels []ChatModel `json:"chat_models,omitempty"` // ModelRequest is the chat_model body and echoed selection. ModelRequest *ChatModelRequest `json:"chat_model,omitempty"` // ChatModes is the chat_modes reply: the permission modes the session's // harness offers, with the session's current mode in ModeRequest. ChatModes []ChatMode `json:"chat_modes,omitempty"` // ModeRequest is the chat_mode body and echoed selection. ModeRequest *ChatModeRequest `json:"chat_mode,omitempty"` // EffortRequest is the chat_effort body and reply, and the chat's current // thinking level on a chat_models reply. EffortRequest *ChatEffortRequest `json:"chat_effort,omitempty"` // ChatSubscribe attaches this connection to one session's shared stream; the // body names the session like ChatQuery. A chat_prompt response sets // ChatQueued when the prompt had to wait for an in-flight turn and was // accepted into the session's queue instead of being sent immediately. ChatSubscribe *ChatQuery `json:"chat_subscribe,omitempty"` ChatQueued bool `json:"chat_queued,omitempty"` // ChatSteered means the prompt was handed to the turn already running; its // reply is that turn's continuing output. ChatSteered bool `json:"chat_steered,omitempty"` // ChatQueue is the session's server-held prompt queue: pushed as a // chat_queue frame when it changes and carried by the chat_subscribe and // chat_unqueue replies. ChatQueue *ChatQueueFrame `json:"chat_queue,omitempty"` // ChatTurnDiffList is the chat_turn_diffs push and the session's recent // turn summaries on a chat_messages reply; ChatTurnDiff is the // chat_turn_diff request and reply (see chat_turn_diff.go). ChatTurnDiffList *ChatTurnDiffList `json:"chat_turn_diffs,omitempty"` ChatTurnDiff *ChatTurnDiff `json:"chat_turn_diff,omitempty"` ChatUnqueue *ChatUnqueueRequest `json:"chat_unqueue,omitempty"` // ChatShown carries the items the chat's model showed through the Pipelines // tools: the retained list on the chat_subscribe reply, one new item on a // pushed chat_shown frame. ChatShown *ChatShownFrame `json:"chat_shown,omitempty"` // ChatDirectories carries the operator's directory choices on a // chat_directories response (home first, then recent operator-session // directories, deduplicated and bounded). Additive/omitempty so older peers // ignore it. ChatDirectories []string `json:"chat_directories,omitempty"` ChatShellOutputQuery *ChatShellOutputQuery `json:"chat_shell_output_query,omitempty"` ChatShells []ChatShell `json:"chat_shells,omitempty"` ChatShellOutput *ChatShellOutputPage `json:"chat_shell_output,omitempty"` // Operator shell commands (chat_shell_run.go): the request body, one run, // a session's runs and the pushed live change. ChatShellRunRequest *ChatShellRunRequest `json:"chat_shell_run_request,omitempty"` ChatShellRun *ChatShellRunRecord `json:"chat_shell_run,omitempty"` ChatShellRuns []ChatShellRunRecord `json:"chat_shell_runs,omitempty"` ChatShellRunEvent *ChatShellRunEventFrame `json:"chat_shell_run_event,omitempty"` // Machine terminals (terminal.go): the request body, one terminal, the // machine's terminals and the pushed change. TerminalRequest *TerminalRequest `json:"terminal_request,omitempty"` Terminal *TerminalRecord `json:"terminal,omitempty"` Terminals []TerminalRecord `json:"terminals,omitempty"` TerminalEvent *TerminalEventFrame `json:"terminal_event,omitempty"` // ListDirectory is the list_directory body and DirectoryListing its reply: // the home-restricted folder picker listing (see directories.go). ListDirectory *DirectoryListRequest `json:"list_directory,omitempty"` DirectoryListing *DirectoryListingResult `json:"directory_listing,omitempty"` // RenamePath, MovePath and DeletePath are the Files panel's home file // mutations and PathMutated their shared reply (see directories.go). RenamePath *RenamePathRequest `json:"rename_path,omitempty"` MovePath *MovePathRequest `json:"move_path,omitempty"` DeletePath *DeletePathRequest `json:"delete_path,omitempty"` PathMutated *PathMutatedResult `json:"path_mutated,omitempty"` // ChatAttachmentImageRequest is the chat_attachment_image body and // ChatAttachmentImage its reply. ChatAttachmentImageRequest *ChatAttachmentImageRequest `json:"chat_attachment_image_request,omitempty"` ChatAttachmentImage *ChatAttachmentImageContent `json:"chat_attachment_image,omitempty"` // ChatAutomations is the provider-owned scheduled-work readback for one // operator session. ActiveCount is omitted when the count is unknown. ChatAutomations *ChatAutomationInfo `json:"chat_automations,omitempty"` // RunEvent is the server-pushed run state delta (see runevents.go) and // RunIDs the optional subscribe scope, so a client asks for the runs it // displays. Both are optional so older peers ignore them. RunEvent *RunEventFrame `json:"run_event,omitempty"` RunIDs []int64 `json:"run_ids,omitempty"` // RunsDeleted is the runs_deleted reply to delete_runs (whose request names // the runs in RunIDs). The runs_removed push carries only RunIDs. RunsDeleted *RunsDeletedResult `json:"runs_deleted,omitempty"` // NotificationSettings is the set_notification_settings partial update and // the notification_settings reply (every key). See notification_settings.go. NotificationSettings map[string]any `json:"notification_settings,omitempty"` // AttentionAcks is the ack_attention body, the attention_acks reply (the // whole set) and the attention_acks_changed push (the delta). See // attention_acks.go. AttentionAcks *AttentionAcks `json:"attention_acks,omitempty"` DiscoveredServers []DiscoveredServer `json:"discovered_servers,omitzero"` ServerStats *ServerStats `json:"server_stats,omitempty"` // App notification stream (see notifications.go): After is the // subscribe_notifications cursor, Notifications the subscribe reply, // Notification one push, and IDs the clear_notifications request, the // notifications_cleared reply/push and the subscribe reply's cleared ids. // Notifications and IDs are present (possibly empty) whenever set. After string `json:"after,omitempty"` Notifications []AppNotification `json:"notifications,omitzero"` Notification *AppNotification `json:"notification,omitempty"` IDs []string `json:"ids,omitzero"` }