Documentation
¶
Overview ¶
Package client is a thin HTTP client for the gofer control plane. It mirrors the /v1/jobs API (plan §7) and reuses the job package's JobRequest/JobResult structs as the wire types so the CLI (P6) and the MCP server (P8) share one transport.
Index ¶
- Constants
- Variables
- func MatchProjectPath(projects []ProjectMeta, cwd string) (key, root string, ok bool)
- func NormalizeBaseURL(addr string) string
- func StatusOf(err error) int
- type AgentHealth
- type AgentMeta
- type AgentProbe
- type AgentSession
- type AssignableProject
- type Client
- func (c *Client) AcceptJob(id, note string) (job.ReviewOutcome, error)
- func (c *Client) AcceptMemoryCandidate(id int64, in job.AcceptMemoryCandidateInput) (job.MemoryCandidateDecision, error)
- func (c *Client) AcceptMergeSuggestion(id int64) (work.DetailView, error)
- func (c *Client) AcceptWorkSuggestion(id, field string) (work.DetailView, error)
- func (c *Client) AddSessionJobWatch(sid, jobID string) (SessionJobWatch, error)
- func (c *Client) AddTodo(planID, title, jobID, note string, patch jobstore.TodoPatch) (Todo, error)
- func (c *Client) AddWorkNote(id, text, level string) error
- func (c *Client) AnswerDecision(id, answer string) (Decision, error)
- func (c *Client) AnswerInteraction(jobID, interactionID, answer, responder string) (job.Interaction, error)
- func (c *Client) AnswerSessionPermission(sid, id, answer string) (Decision, error)
- func (c *Client) AskDecision(planID, title, question string, options []string, timeoutSec int64) (Decision, error)
- func (c *Client) AttachJob(planID, jobID string) (Plan, error)
- func (c *Client) AttachWorkSession(id, sid string) (work.DetailView, error)
- func (c *Client) BaseURL() string
- func (c *Client) CancelJob(id string) (job.JobResult, error)
- func (c *Client) CancelRetry(id string) error
- func (c *Client) CancelWorkflow(id string) (Workflow, error)
- func (c *Client) CompleteSessionWatchTurn(sid, turnID string, jobIDs []string) (bool, error)
- func (c *Client) CompleteSessionWatches(sid string, jobIDs []string) (bool, error)
- func (c *Client) CreatePlan(planID, title, description, project, leader string, tags ...[]string) (Plan, error)
- func (c *Client) CreatePlanAutoSupervisor(planID, title, description, project, leader string, tags []string, ...) (Plan, SupervisorAutoBind, error)
- func (c *Client) CreatePlanWithSupervisorSession(planID, title, description, project, leader, supervisorSessionID string, ...) (Plan, error)
- func (c *Client) CreateSchedule(req CreateScheduleRequest) (Schedule, error)
- func (c *Client) CreateScopedMemory(scope, scopeKey, key, content string, tags []string, meta *tracker.MemoryMeta) (ScopedMemory, error)
- func (c *Client) CreateSessionNudge(sid, kind string, intervalSec int64, text string, untilAt int64) (SessionNudge, error)
- func (c *Client) CreateWakeup(jobID string, spec job.WakeupSpec) (Wakeup, error)
- func (c *Client) CreateWorkItem(fields map[string]any) (work.DetailView, error)
- func (c *Client) DeleteJob(id string) error
- func (c *Client) DeleteSchedule(id string) error
- func (c *Client) DeleteScopedMemory(scope, scopeKey, key string) error
- func (c *Client) DeleteSession(sid string) error
- func (c *Client) DeleteSessionNudge(id string) error
- func (c *Client) DeleteTunnelPreset(name string) error
- func (c *Client) DeleteWakeup(id string) error
- func (c *Client) DeleteWorkItems(ids []string, status string) (work.DeleteResult, error)
- func (c *Client) DeliverSession(sid, text string, allowTakeover bool) (SessionDeliverResult, error)
- func (c *Client) DeregisterAgent(agentID, token string) error
- func (c *Client) DetachWorkSession(id, sid string) (work.DetailView, error)
- func (c *Client) DialTunnel(ctx context.Context, workerID, target string, networks ...string) (TunnelConn, error)
- func (c *Client) DismissMergeSuggestion(id int64) error
- func (c *Client) DismissWorkSuggestion(id, field string) (work.DetailView, error)
- func (c *Client) DispatchTodo(todoID string) (TodoDispatch, error)
- func (c *Client) EndJob(id string) (job.JobResult, error)
- func (c *Client) ExportWorkflow(id string) (workflow.Spec, bool, error)
- func (c *Client) FlagScopedMemory(scope, scopeKey, key, reason, jobID string) (ScopedMemory, error)
- func (c *Client) GetDecision(id string) (Decision, error)
- func (c *Client) GetInteractions(id string) ([]job.Interaction, error)
- func (c *Client) GetJob(id string) (job.JobResult, error)
- func (c *Client) GetJobDiffFull(id string) (string, error)
- func (c *Client) GetJobRequest(id string) (job.JobRequest, error)
- func (c *Client) GetJobWorktree(id string) (job.WorktreeStatus, error)
- func (c *Client) GetLogs(id, stream string) (string, error)
- func (c *Client) GetLogsTail(id, stream string, maxBytes int) (string, error)
- func (c *Client) GetLogsWindow(id string, opts LogOpts) (string, error)
- func (c *Client) GetPlan(id string) (Plan, error)
- func (c *Client) GetPlanHandoff(id string, version int) (PlanHandoff, error)
- func (c *Client) GetSchedule(id string) (Schedule, error)
- func (c *Client) GetScopedMemory(scope, scopeKey, key string) (ScopedMemory, error)
- func (c *Client) GetServerTZOffset() (offset int, ok bool, err error)
- func (c *Client) GetSession(sid string, limit int, before string) (SessionDetail, error)
- func (c *Client) GetTemplate(projectKey, name string, vars map[string]string) (template.Preview, error)
- func (c *Client) GetTunnelPreset(name string) (TunnelPreset, error)
- func (c *Client) GetUsageStats() (StatsUsage, error)
- func (c *Client) GetWakeup(id string) (Wakeup, error)
- func (c *Client) GetWorkItem(id string) (work.DetailView, error)
- func (c *Client) GetWorker(id string) (WorkerDetail, error)
- func (c *Client) GetWorkerProjects(id string) (WorkerDetail, error)
- func (c *Client) GetWorkflow(id string) (Workflow, error)
- func (c *Client) HeartbeatSession(sid string, hb SessionHeartbeat) (AgentSession, error)
- func (c *Client) HeartbeatTunnelForwarder(id string, specs []TunnelSpecView) (TunnelForwarder, error)
- func (c *Client) ImportLocalTunnelPreset(name string) (TunnelPreset, error)
- func (c *Client) IssueGet(id, trackerID string) (IssueGetResp, error)
- func (c *Client) IssueList(o IssueListOpts) (IssueListResp, error)
- func (c *Client) LinkWork(id, kind, ref string) (work.DetailView, error)
- func (c *Client) ListAgents() ([]AgentMeta, error)
- func (c *Client) ListArtifacts(id string) (json.RawMessage, error)
- func (c *Client) ListComments(scope, id string) ([]Comment, error)
- func (c *Client) ListDecisions(state, planID string) ([]Decision, error)
- func (c *Client) ListJobs(opts job.ListOpts) ([]job.JobResult, error)
- func (c *Client) ListLocalTunnelPresets() ([]TunnelPreset, error)
- func (c *Client) ListMemoryCandidates(o MemoryCandidateListOpts) ([]jobstore.MemoryCandidate, error)
- func (c *Client) ListMergeSuggestions() ([]jobstore.WorkMergeSuggestion, error)
- func (c *Client) ListPendingInteractions() ([]job.Interaction, error)
- func (c *Client) ListPlanHandoffHistory(id string) ([]PlanHandoff, error)
- func (c *Client) ListPlans(opts PlanListOpts) (PlanList, error)
- func (c *Client) ListPresence(role, project string) ([]presence.Agent, error)
- func (c *Client) ListProjects() ([]ProjectMeta, error)
- func (c *Client) ListRetries(jobID string) ([]Retry, error)
- func (c *Client) ListRunners() ([]RunnerMeta, error)
- func (c *Client) ListSchedules(project string) ([]Schedule, error)
- func (c *Client) ListScopedMemories(opts ScopedMemoryListOpts) ([]ScopedMemory, error)
- func (c *Client) ListSessionJobWatches(sid string) ([]SessionJobWatch, error)
- func (c *Client) ListSessionMessages(sid string) ([]SessionMessage, error)
- func (c *Client) ListSessionNudges(sid string, all bool) ([]SessionNudge, error)
- func (c *Client) ListSessions(opts SessionListOpts) ([]AgentSession, error)
- func (c *Client) ListTemplates(projectKey string) ([]template.Info, error)
- func (c *Client) ListTunnelForwarders() ([]TunnelForwarder, error)
- func (c *Client) ListTunnelPresets() ([]TunnelPreset, error)
- func (c *Client) ListTunnels() ([]TunnelInfo, error)
- func (c *Client) ListWakeups(jobID string) ([]Wakeup, error)
- func (c *Client) ListWorkItems(o WorkListOpts) (WorkList, error)
- func (c *Client) ListWorkRequests(id string, activeOnly bool, limit int) ([]jobstore.WorkRequest, error)
- func (c *Client) ListWorkers() ([]WorkerMeta, error)
- func (c *Client) ListWorkflowEvents(id string, sinceSeq int64) ([]WorkflowEvent, error)
- func (c *Client) ListWorkflowTemplates(name, project string) ([]workflow.WorkflowTemplate, error)
- func (c *Client) ListWorkflows(status string) ([]Workflow, error)
- func (c *Client) LookupCurrentAgentSession(getenv func(string) string, project string) SupervisorAutoBind
- func (c *Client) MemoryFindings(trackerID string, all bool) ([]today.MemoryFinding, error)
- func (c *Client) MergeJobWorktree(id string, squash, cleanupOthers bool) (job.MergeResult, error)
- func (c *Client) MergeSuggest(targetID, sourceID, reason string) (jobstore.WorkMergeSuggestion, bool, error)
- func (c *Client) MergeWorkItems(target string, sources []string) (work.DetailView, error)
- func (c *Client) Meta() (Meta, error)
- func (c *Client) OpenSessionPermission(sid string, p SessionPermission) (Decision, error)
- func (c *Client) OpenSessionTurn(sid, msg string, timeoutSec int64) (Decision, error)
- func (c *Client) OpenStream(ctx context.Context, id string) (*http.Response, error)
- func (c *Client) PatchTodo(todoID string, u TodoUpdate) (Todo, error)
- func (c *Client) PatchWorkItem(id string, fields map[string]any) (work.DetailView, error)
- func (c *Client) PausePlan(planID string) (Plan, error)
- func (c *Client) PickWorkflowFan(id string, step, fan int) (Workflow, error)
- func (c *Client) PollInbox(agentID, token string, ack bool) ([]presence.Message, error)
- func (c *Client) PostComment(scope, id, body string) (Comment, error)
- func (c *Client) PostMessage(from, to, kind, body, ref string) (int, error)
- func (c *Client) ProbeAgent(key, project string, timeoutSec int) (AgentProbe, error)
- func (c *Client) PuntInteraction(jobID, interactionID string) error
- func (c *Client) PutScopedMemory(scope, scopeKey, key, content string, tags []string) (ScopedMemory, error)
- func (c *Client) PutStewardNotes(body string, version int) (StewardNotesResp, error)
- func (c *Client) PutTunnelPreset(name string, p TunnelPreset, force bool) (TunnelPreset, error)
- func (c *Client) RebuildJob(id string, ov job.RebuildOverrides) (job.JobResult, error)
- func (c *Client) RedactJob(id string, req JobRedactRequest) (jobstore.RedactReport, error)
- func (c *Client) RedactJobSecrets(req JobSecretScanRequest) (jobstore.SecretBatchRedactReport, error)
- func (c *Client) RegisterAgent(name, role, project string) (agentID, token string, err error)
- func (c *Client) RegisterSession(in SessionRegister) (AgentSession, error)
- func (c *Client) RegisterTunnelForwarder(reg TunnelForwarderRegistration) (TunnelForwarder, error)
- func (c *Client) RegisterWorker(id string, labels, projects []string) (WorkerRegistration, error)
- func (c *Client) RejectJob(id, note string, resume bool) (job.ReviewOutcome, error)
- func (c *Client) RejectMemoryCandidate(id int64) (jobstore.MemoryCandidate, error)
- func (c *Client) ReleaseSessionTakeover(sid string) (AgentSession, error)
- func (c *Client) ReleaseSessionTurn(sid, decisionID string, idleSec int64) (bool, error)
- func (c *Client) ReloadWorker(workerID, reason string, wait time.Duration) (WorkerReload, error)
- func (c *Client) RemoveJobWorktree(id string, force, deleteBranch bool) (job.WorktreeStatus, error)
- func (c *Client) RemoveSessionJobWatch(sid, jobID string) error
- func (c *Client) RemoveWorker(id string) error
- func (c *Client) RenameTrackerRepo(oldID, newID string) (TrackerRenameResult, error)
- func (c *Client) ReportWork(id string, fields map[string]any) (work.DetailView, error)
- func (c *Client) RequestWorkReport(id, sessionID, kind string) (bool, []WorkReportRequestResult, error)
- func (c *Client) ResolveSessionPermission(sid, fp string) (int, error)
- func (c *Client) ResumeJob(id, prompt, runner string) (job.JobResult, error)
- func (c *Client) ResumeJobWith(id, prompt, runner string, opts job.ResumeOptions) (job.JobResult, error)
- func (c *Client) ResumePlan(planID string) (Plan, error)
- func (c *Client) ResumeSession(sid, input string) (SessionDeliverResult, error)
- func (c *Client) RotateScheduleToken(id string) (Schedule, error)
- func (c *Client) RuleList() ([]rule.Rule, error)
- func (c *Client) RuleRemove(name string) error
- func (c *Client) RuleSet(name string, content []byte) (RuleView, error)
- func (c *Client) RuleShow(name string) (RuleView, error)
- func (c *Client) RunPlan(planID string) (Plan, error)
- func (c *Client) RunSchedule(id string) (job.JobResult, error)
- func (c *Client) RunnersOverview() (RunnersOverview, error)
- func (c *Client) SayJob(id, message string) (job.JobResult, error)
- func (c *Client) SaySession(sid, answer string) (Decision, error)
- func (c *Client) ScanJobSecrets(req JobSecretScanRequest) (jobstore.SecretScanReport, error)
- func (c *Client) SendSessionMessage(sid, message string) (SessionMessage, error)
- func (c *Client) SessionAsk(sid, text, workID string) (work.AskResult, error)
- func (c *Client) SessionTail(sid string, bytes int64) (work.SessionTailResult, error)
- func (c *Client) SessionTakeoverPlan(sid string) (SessionResumePlan, error)
- func (c *Client) SetJobTitle(id, title string) (job.JobResult, error)
- func (c *Client) SetPlanHandoff(id, body string, expectedVersion int) (PlanHandoff, error)
- func (c *Client) SetPlanLeader(planID, leader string) (Plan, error)
- func (c *Client) SetPlanSupervisorSessionID(planID string, sessionID *string) (Plan, error)
- func (c *Client) SetScheduleEnabled(id string, enable bool) (Schedule, error)
- func (c *Client) SetSessionNudgeState(id, state string) (SessionNudge, error)
- func (c *Client) SetSessionRelayMode(sid, mode string) (AgentSession, error)
- func (c *Client) SetWakeupEnabled(id string, enabled bool) (Wakeup, error)
- func (c *Client) SkillExport(name string, w io.Writer) error
- func (c *Client) SkillImportFile(path string) (SkillImportResult, error)
- func (c *Client) SkillImportSource(src string) (SkillImportResult, error)
- func (c *Client) SkillList() ([]skill.Skill, error)
- func (c *Client) SkillRemove(name string) error
- func (c *Client) SkillShow(name string) (SkillView, error)
- func (c *Client) SkillUpdate(name string) (SkillUpdateResult, error)
- func (c *Client) SplitWorkItem(id, title, goal string, sessionIDs []string, keep bool) (WorkSplitResult, error)
- func (c *Client) StageWorkerUpgrade(id, path string) (sha256 string, size int64, err error)
- func (c *Client) StartHostedTunnelForwarder(name string) (TunnelForwarder, string, error)
- func (c *Client) StartWorkerUpgrade(id string, opt WorkerUpgradeOptions) (WorkerUpgradeRecord, error)
- func (c *Client) StatsBackfill(req StatsBackfillRequest) (StatsBackfillResult, error)
- func (c *Client) StewardAsk(text string) (steward.AskResult, error)
- func (c *Client) StewardNotes(version int) (StewardNotesResp, error)
- func (c *Client) StewardNotesHistory() ([]steward.Notes, error)
- func (c *Client) StewardRestart() (steward.StartResult, error)
- func (c *Client) StewardReview(force bool) (steward.ReviewResult, error)
- func (c *Client) StewardReviewSummary(text string) error
- func (c *Client) StewardStart() (steward.StartResult, error)
- func (c *Client) StewardStatus() (StewardState, error)
- func (c *Client) StewardStop() (bool, error)
- func (c *Client) StopHostedTunnelForwarder(name string) error
- func (c *Client) StopTunnelForwarder(id string) (TunnelForwarder, error)
- func (c *Client) StreamJob(ctx context.Context, id string, from int, onEvent func(SSEEvent)) error
- func (c *Client) SubmitJob(req job.JobRequest) (job.JobResult, error)
- func (c *Client) SubmitJobSync(req job.JobRequest) (SubmitResult, error)
- func (c *Client) SubmitMarkdown(body []byte) (SubmitResult, error)
- func (c *Client) SubmitWorkflow(spec workflow.Spec) (Workflow, error)
- func (c *Client) SubmitWorkflowTemplate(name string, vars map[string]string) (Workflow, error)
- func (c *Client) SuggestMemory(in today.MemorySuggestInput) (today.MemorySuggestion, bool, error)
- func (c *Client) SummarizeWork(id string) (jobstore.WorkRequest, error)
- func (c *Client) SyncTrackerRepo(trackerID string) (TrackerRepoSyncResult, error)
- func (c *Client) Today(includeExec bool) (today.Response, error)
- func (c *Client) TodayAdvise(in today.AdviceInput) (today.Advice, error)
- func (c *Client) Token() string
- func (c *Client) UnflagScopedMemory(scope, scopeKey, key string) (ScopedMemory, error)
- func (c *Client) UnlinkWork(id, kind, ref string) (work.DetailView, error)
- func (c *Client) UnregisterTunnelForwarder(id string) error
- func (c *Client) UpdatePlan(planID, status string, progress *int) (Plan, error)
- func (c *Client) UpdatePlanTags(planID string, tags *[]string, untag []string) (Plan, error)
- func (c *Client) UpdateTodo(todoID string, done bool) (Todo, error)
- func (c *Client) WaitSessionTurn(sid, decisionID string, waitSec int) (TurnStatus, error)
- func (c *Client) WatchJob(ctx context.Context, id string, from int, h WatchHandlers) (final string, err error)
- func (c *Client) WatchWorkflow(ctx context.Context, id string, onStep func(st WorkflowStep)) (Workflow, error)
- func (c *Client) WorkDigest(send bool) (work.Digest, int, error)
- func (c *Client) WorkSummarizerStatus() (map[string]any, error)
- func (c *Client) WorkToTodo(id, planID, newPlanTitle string) (WorkToTodoResult, error)
- func (c *Client) WorkerAssignable(workerID string) (WorkerAssignable, error)
- func (c *Client) XferDownload(ctx context.Context, id, destPath string) (int64, string, error)
- func (c *Client) XferGet(ctx context.Context, runner, project, path string) (XferRecord, error)
- func (c *Client) XferList(state, runner string) ([]XferRecord, error)
- func (c *Client) XferPrecheck(ctx context.Context, runner, project, path string, size int64, force bool) error
- func (c *Client) XferPut(ctx context.Context, runner, project, path, localPath string, force bool, ...) (XferRecord, error)
- func (c *Client) XferRemove(id string) error
- func (c *Client) XferStage(ctx context.Context, runner, project, path, localPath string) (XferRecord, error)
- func (c *Client) XferStatus(id string) (XferRecord, error)
- type Comment
- type CommentDispatch
- type CreateScheduleRequest
- type Decision
- type ErrStewardNotesConflict
- type IssueBrief
- type IssueGetResp
- type IssueListOpts
- type IssueListResp
- type JobRedactRequest
- type JobSecretScanRequest
- type LogOpts
- type MemoryCandidateListOpts
- type Meta
- type MetaAgent
- type MetaRunner
- type PermissionSuggestionLabel
- type Plan
- type PlanHandoff
- type PlanLeaderRound
- type PlanList
- type PlanListOpts
- type PlanSessionUsage
- type PlanUsage
- type ProjectMeta
- type RetriesResp
- type Retry
- type RuleView
- type RunnerAgentMeta
- type RunnerCapabilities
- type RunnerMeta
- type RunnerServer
- type RunnerWorkerBrief
- type RunnerWorkerDetail
- type RunnersOverview
- type SSEEvent
- type Schedule
- type ScopedMemory
- type ScopedMemoryListOpts
- type SessionCandidate
- type SessionDeliverResult
- type SessionDetail
- type SessionHeartbeat
- type SessionJobWatch
- type SessionListOpts
- type SessionMessage
- type SessionNudge
- type SessionPermission
- type SessionRegister
- type SessionResumePlan
- type SkillImportResult
- type SkillUpdateResult
- type SkillView
- type StatsBackfillRequest
- type StatsBackfillResult
- type StatsUsage
- type StatusError
- type StewardNotesResp
- type StewardSettings
- type StewardState
- type SubmitResult
- type SupervisorAutoBind
- type Todo
- type TodoDispatch
- type TodoJob
- type TodoUpdate
- type TrackerRenameResult
- type TrackerRepoSyncResult
- type TunnelConn
- type TunnelError
- type TunnelForwarder
- type TunnelForwarderRegistration
- type TunnelInfo
- type TunnelPreset
- type TunnelSpecView
- type TurnStatus
- type UsageAgent
- type UsageWindow
- type Wakeup
- type WakeupsResp
- type WatchHandlers
- type WorkList
- type WorkListOpts
- type WorkReportRequestResult
- type WorkSplitResult
- type WorkToTodoResult
- type WorkerAssignable
- type WorkerCaps
- type WorkerDetail
- type WorkerMeta
- type WorkerRegistration
- type WorkerReload
- type WorkerUpgradeOptions
- type WorkerUpgradeRecord
- type Workflow
- type WorkflowEvent
- type WorkflowStep
- type XferRecord
Constants ¶
const ( WaitModeOn = "mode_on" WaitIdleProbe = "idle_probe" WaitTurnAge = "turn_age" )
Relay wait reasons reported by the server (see sessionrelay.WaitReason); the Stop hook picks its poll cadence from these.
const ( RelayModeAuto = "auto" RelayModeOn = "on" RelayModeOff = "off" )
Relay modes the switch can be set to (R1; server-side source of truth is jobstore.RelayMode*): `on` always waits, `off` never does, `auto` lets the server's idle / turn-age rules decide.
const ( WorkerUpgradePending = "pending" WorkerUpgradeSucceeded = "succeeded" WorkerUpgradeRolledBack = "rolled_back" WorkerUpgradeFailed = "failed" )
Worker upgrade states (mirror of workerupgrade.State*; the client keeps its own wire types so commands never import server packages).
const ( XferOpPut = "put" XferOpGet = "get" )
Transfer operations: a put uploads bytes into the staging area for the runner to write, a get asks the runner to read a file out of its project root.
const ( XferStateStaged = "staged" XferStateDispatched = "dispatched" XferStateDone = "done" XferStateFailed = "failed" XferStateExpired = "expired" )
Transfer states as the wire reports them (server side: internal/xfer). They are re-exported so a caller can poll without depending on the server's own package.
const AgentSessionLookupTimeout = 3 * time.Second
AgentSessionLookupTimeout bounds the "is this a registered session" probe that plan auto-binding runs before creating a plan: binding is a convenience and must never make `plan create` hang on a slow server.
const ForwarderCapStop = "stop"
ForwarderCapStop is the capability a forwarder advertises when it exits on a remote stop (the heartbeat's 410 Gone).
Variables ¶
var AgentSessionEnvKeys = []string{"GOFER_SESSION_ID", "CLAUDE_CODE_SESSION_ID", "CODEX_THREAD_ID", "CODEX_SESSION_ID"}
AgentSessionEnvKeys are the environment variables an agent terminal session exports to the commands it runs, in the order a plan created from that session looks for "the current session":
- GOFER_SESSION_ID: explicit, set by the user or any generic agent wrapper;
- CLAUDE_CODE_SESSION_ID: Claude Code (the same id its hooks register);
- CODEX_THREAD_ID / CODEX_SESSION_ID: Codex CLI (both carry the thread id its hooks register as session_id).
Functions ¶
func MatchProjectPath ¶
func MatchProjectPath(projects []ProjectMeta, cwd string) (key, root string, ok bool)
MatchProjectPath finds the project whose host_path or container_path contains cwd, longest prefix wins. A tie between different projects matches nothing. root is the matched path. Both views are tried because a client node may sit on the host or inside a container.
func NormalizeBaseURL ¶
NormalizeBaseURL makes a user-supplied server address connectable:
- a bare `host:port` (or `host`) gets an `http://` scheme;
- a `0.0.0.0` host (the default listen address, not a connectable address) is rewritten to `127.0.0.1`;
- a trailing slash is trimmed.
Types ¶
type AgentHealth ¶
type AgentHealth struct {
State string `json:"state"`
WindowSec int `json:"window_sec"`
Jobs int `json:"jobs"`
OK int `json:"ok"`
TransientFail int `json:"transient_fail"`
LastTransientAt int64 `json:"last_transient_at,omitempty"`
LastOKAt int64 `json:"last_ok_at,omitempty"`
}
AgentHealth is one agent's recent-job health as GET /v1/agents reports it (SUP-01 P3): the classified state plus the evidence behind it.
type AgentMeta ¶
type AgentMeta struct {
Name string `json:"name"`
Type string `json:"type"`
Available bool `json:"available"`
Detail string `json:"detail,omitempty"`
// Health is the agent's recent-job health (SUP-01 P3), nil when the server
// reported none (older server, or the aggregate could not be read).
Health *AgentHealth `json:"health,omitempty"`
}
AgentMeta is one agent as the mcp bridge contract exposes it (name/type/available/detail), matching mcpserver.agentEntry so the client backend (E28 P3) can map it 1:1. The /v1/agents endpoint actually returns the httpapi.agentView wire shape (key/type/available/version/error); ListAgents folds that into this view (name=key, detail=version when available else the probe error), exactly like the local mcpserver handler does.
type AgentProbe ¶
type AgentProbe struct {
JobID string `json:"job_id"`
Status string `json:"status"`
ExitCode int `json:"exit_code"`
DurationMs int64 `json:"duration_ms"`
FirstLine string `json:"first_line,omitempty"`
}
AgentProbe is the outcome of a probe (POST /v1/agents/{key}/probe, SUP-01 P3): the ordinary job that carried it, its terminal status, and the first line the agent produced.
type AgentSession ¶
type AgentSession struct {
SessionID string `json:"session_id"`
Agent string `json:"agent"`
ProjectKey string `json:"project_key,omitempty"`
Runner string `json:"runner,omitempty"`
Cwd string `json:"cwd,omitempty"`
Title string `json:"title,omitempty"`
Transcript string `json:"transcript,omitempty"`
TmuxPane string `json:"tmux_pane,omitempty"`
State string `json:"state"`
// RelayMode is the three-state switch (auto|on|off, R1). WaitReason reports
// whether a Stop would wait right now and why (mode_on / idle_probe /
// turn_age; empty = it would not wait) — it is what the Stop hook keys on.
RelayMode string `json:"relay_mode"`
// RelayDemotedAt: when `on` fell back to `auto` because the human typed in the
// terminal (single-session reads; 0 = not the current story).
RelayDemotedAt int64 `json:"relay_demoted_at,omitempty"`
WaitReason string `json:"wait_reason,omitempty"`
// WaitReasonDetail explains a session that does NOT wait right now (SUP-01 D):
// "supervising N jobs". The hook only logs it.
WaitReasonDetail string `json:"wait_reason_detail,omitempty"`
// WaitBudgetSec caps how long the Stop hook blocks for a reply (0 = the server
// gave no cap); SubagentCount is the sub-agents running in the session.
WaitBudgetSec int `json:"wait_budget_sec,omitempty"`
SubagentCount int `json:"subagent_count,omitempty"`
// PermissionWaitReason / PermissionWaitBudgetSec are the same verdict for a
// terminal PERMISSION prompt: no supervising gate (the dialog blocks the terminal
// anyway). Empty on a server that predates them — the hook then falls back to
// WaitReason / WaitBudgetSec.
PermissionWaitReason string `json:"permission_wait_reason,omitempty"`
PermissionWaitBudgetSec int `json:"permission_wait_budget_sec,omitempty"`
// CallerID is the authenticated caller that registered the session (its
// owner): who may answer it, and whose live jobs keep it from auto-arming.
CallerID string `json:"caller_id,omitempty"`
TurnNo int64 `json:"turn_no"`
LastMessage string `json:"last_message,omitempty"`
LastEvent string `json:"last_event,omitempty"`
LastSeenAt int64 `json:"last_seen_at"`
StartedAt int64 `json:"started_at"`
EndedAt int64 `json:"ended_at,omitempty"`
// AutoArmed reports that the server's KEYBOARD IDLE rule alone arms relay for
// this session (the human has been away for >= session.auto_relay_idle_sec);
// IdleSec is the idle reading the hook reported last, -1 = unknown.
// LastHumanAt is when a human last acted here (0 = never), the anchor of the
// turn-age fallback.
AutoArmed bool `json:"auto_armed"`
IdleSec int64 `json:"idle_sec"`
// HandedOffJobID is set while the session is taken over by path B's pty job
// (§9.1 B); Notice is the one-liner the hook prints on stderr so the person at
// the ORIGINAL terminal learns where the conversation went.
HandedOffJobID string `json:"handed_off_job_id,omitempty"`
HandedOffAt int64 `json:"handed_off_at,omitempty"`
Notice string `json:"notice,omitempty"`
LastHumanAt int64 `json:"last_human_at,omitempty"`
WatchCount int `json:"watch_count,omitempty"`
PeerName string `json:"peer_name,omitempty"`
// PeerNameSource is where Claude Code says the name came from (user / auto...).
PeerNameSource string `json:"peer_name_source,omitempty"`
PeerStatus string `json:"peer_status,omitempty"`
PeerMessaging bool `json:"peer_messaging"`
ProgressText string `json:"progress_text,omitempty"`
ProgressAt int64 `json:"progress_at,omitempty"`
// LastCwd is the directory the hook last reported (display only).
LastCwd string `json:"last_cwd,omitempty"`
}
AgentSession mirrors httpapi's sessionView (a terminal agent-CLI session registered through its hooks). Timestamps are unix seconds.
type AssignableProject ¶
type AssignableProject struct {
Key string `json:"key"`
HostPath string `json:"host_path,omitempty"`
}
AssignableProject is one project a worker may be dispatched to, as returned by GET /v1/workers/{id}/assignable. HostPath is the SERVER's logical path — what a worker's `roots` must map onto a local tree.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a running gofer server. It is safe for sequential use; the zero value is not usable — construct it with New.
func New ¶
New builds a Client for baseURL with an optional bearer token. baseURL is normalised (scheme added, 0.0.0.0 rewritten to 127.0.0.1) via NormalizeBaseURL so callers may pass a bare `host:port`. When token is empty no Authorization header is sent (the server must then allow empty-token auth).
func NewWithTimeout ¶
NewWithTimeout is New with a caller-selected HTTP deadline, used by best-effort session-prime lookups so an unreachable server cannot delay a hook.
func (*Client) AcceptJob ¶
func (c *Client) AcceptJob(id, note string) (job.ReviewOutcome, error)
AcceptJob POSTs to /v1/jobs/{id}/accept, recording a human's ACCEPTANCE of a needs_review job (GATE-01 S3): the job becomes done and the reviewer/note are kept as its audit trail. note is optional.
There is no in-job identity to declare: since SEC-01 a job authenticates with its OWN credential (GOFER_JOB_TOKEN), and the server refuses accept/reject for every job caller from that credential — not from anything the body claims.
func (*Client) AcceptMemoryCandidate ¶
func (c *Client) AcceptMemoryCandidate(id int64, in job.AcceptMemoryCandidateInput) (job.MemoryCandidateDecision, error)
AcceptMemoryCandidate files candidate id as a scoped memory.
func (*Client) AcceptMergeSuggestion ¶
func (c *Client) AcceptMergeSuggestion(id int64) (work.DetailView, error)
AcceptMergeSuggestion is a person's yes: it performs the merge.
func (*Client) AcceptWorkSuggestion ¶
func (c *Client) AcceptWorkSuggestion(id, field string) (work.DetailView, error)
AcceptWorkSuggestion adopts a pending suggestion ("goal", "blocker", "next", ...).
func (*Client) AddSessionJobWatch ¶
func (c *Client) AddSessionJobWatch(sid, jobID string) (SessionJobWatch, error)
AddSessionJobWatch registers a job for the session's Stop hook.
func (*Client) AddTodo ¶
AddTodo creates a plan todo. jobID may be empty for a plain checklist item; note is an optional short remark. patch carries the PLAN-02 dispatch fields; the item is created `pending`, so nothing is dispatched until it is set ready.
func (*Client) AddWorkNote ¶
AddWorkNote appends a note to the journal. level is optional (milestone | detail; "" = the server's default for the caller).
func (*Client) AnswerDecision ¶
AnswerDecision POSTs /v1/decisions/{id}/answer. A non-2xx surfaces via errorFor: unknown id → 404 error, already answered/expired → 409 error.
func (*Client) AnswerInteraction ¶
func (c *Client) AnswerInteraction(jobID, interactionID, answer, responder string) (job.Interaction, error)
AnswerInteraction POSTs an answer to a peer interaction (P9 passthrough / E28 client mode) and returns the updated job.Interaction the server echoes back (the answer endpoint returns a bare job.Interaction). Fire-and-forget callers may ignore the returned Interaction. responder is the answering driver's agent_id (监督派生作答闸 P3.1) forwarded so the central serve grades the source; "" = unattributed (human/relay), omitted from the body.
func (*Client) AnswerSessionPermission ¶
AnswerSessionPermission answers a pending prompt: allow | always:<i> | deny[:<reason>].
func (*Client) AskDecision ¶
func (c *Client) AskDecision(planID, title, question string, options []string, timeoutSec int64) (Decision, error)
AskDecision POSTs /v1/decisions and returns the created OPEN decision. planID may be "" (global question); options empty = free-text answer. timeoutSec <= 0 / out-of-range values are clamped server-side (the authoritative clamp lives in jobstore.InsertDecision, plan HIGH-2).
func (*Client) AttachWorkSession ¶
func (c *Client) AttachWorkSession(id, sid string) (work.DetailView, error)
AttachWorkSession makes a session a current session of the item.
func (*Client) BaseURL ¶
BaseURL exposes the normalized endpoint for narrow extension APIs such as repository tracker sync; request authentication remains owned by Client.
func (*Client) CancelJob ¶
CancelJob POSTs to /v1/jobs/{id}/cancel and returns the resulting snapshot. Cancelling a terminal job is a stable no-op server-side.
func (*Client) CancelRetry ¶
CancelRetry drops one retry that has not run yet (pending, or claimed) so the sweeper will not submit it. A retry that already ran or was already cancelled is terminal: the server answers 404 and this returns that error.
func (*Client) CancelWorkflow ¶
CancelWorkflow POSTs to /v1/workflows/{id}/cancel and returns the resulting header snapshot. Cancelling a terminal workflow is a stable no-op server-side.
func (*Client) CompleteSessionWatchTurn ¶
func (*Client) CompleteSessionWatches ¶
CompleteSessionWatches marks terminal watched jobs delivered without a relay turn (Stop with relay off, and the UserPromptSubmit / SessionStart catch-up). completed=false: another hook delivered them first.
func (*Client) CreatePlan ¶
func (c *Client) CreatePlan(planID, title, description, project, leader string, tags ...[]string) (Plan, error)
CreatePlan POSTs /v1/plans and returns the created header. project is the project its todos are dispatched into (PLAN-02 P2); "" names none. leader is "" (off / not asked for), "on" or "off" (LEAD-02).
func (*Client) CreatePlanAutoSupervisor ¶
func (c *Client) CreatePlanAutoSupervisor(planID, title, description, project, leader string, tags []string, getenv func(string) string) (Plan, SupervisorAutoBind, error)
CreatePlanAutoSupervisor creates a plan bound to the agent session the caller runs in (LookupCurrentAgentSession). When no session is found, or the server refuses the binding (session not owned by this caller / no authenticated caller), the plan is created unbound and the result's Reason says why — the binding never fails the plan.
func (*Client) CreatePlanWithSupervisorSession ¶
func (c *Client) CreatePlanWithSupervisorSession(planID, title, description, project, leader, supervisorSessionID string, tags ...[]string) (Plan, error)
CreatePlanWithSupervisorSession creates a plan and optionally binds the authenticated terminal session that will supervise its dispatches.
func (*Client) CreateSchedule ¶
func (c *Client) CreateSchedule(req CreateScheduleRequest) (Schedule, error)
CreateSchedule creates a cron schedule via POST /v1/schedules.
func (*Client) CreateScopedMemory ¶
func (c *Client) CreateScopedMemory(scope, scopeKey, key, content string, tags []string, meta *tracker.MemoryMeta) (ScopedMemory, error)
CreateScopedMemory upserts a scoped memory. A non-nil meta sends every meta field (the caller passes the merged record, so empty values clear); nil keeps the stored ones.
func (*Client) CreateSessionNudge ¶
func (c *Client) CreateSessionNudge(sid, kind string, intervalSec int64, text string, untilAt int64) (SessionNudge, error)
CreateSessionNudge sets a nudge on a session (POST /v1/sessions/{sid}/nudges).
func (*Client) CreateWakeup ¶
CreateWakeup registers a wakeup on a job (POST /v1/jobs/{id}/wakeups). spec.JobID is taken from the path, so a body value is ignored.
func (*Client) CreateWorkItem ¶
CreateWorkItem creates a work item; fields: title (required), goal, status, project_key, workspace, next_step, priority, session_ids.
func (*Client) DeleteSchedule ¶
DeleteSchedule deletes one schedule by id.
func (*Client) DeleteScopedMemory ¶
func (*Client) DeleteSession ¶
DeleteSession removes a session registration.
func (*Client) DeleteSessionNudge ¶
DeleteSessionNudge removes a nudge.
func (*Client) DeleteTunnelPreset ¶
DeleteTunnelPreset removes one preset.
func (*Client) DeleteWakeup ¶
DeleteWakeup removes a wakeup (DELETE /v1/wakeups/{id}).
func (*Client) DeleteWorkItems ¶
DeleteWorkItems permanently deletes finished (done / dropped) work items: the listed ids and/or every item in status (dropped | done). Items that cannot go are reported in Failed rather than failing the call.
func (*Client) DeliverSession ¶
func (c *Client) DeliverSession(sid, text string, allowTakeover bool) (SessionDeliverResult, error)
DeliverSession sends a reply to a session that is NOT waiting for one (POST /v1/sessions/{sid}/deliver, design §9.1): an OPEN turn is answered like SaySession, otherwise the text is typed into the session's tmux pane. With allowTakeover the server may instead start a NEW `--resume` process when the session has no usable pane (path B) — that moves the conversation off the terminal the human left, so it is opt-in.
A 409 means the session cannot be reached (its body names the reason: no_runner / no_tmux / ended / handed_off:<job> / no_resume_template / interactive_not_allowed / cwd_outside_project), 502 that the dispatch failed, 400 that the text is empty or over 8KB.
func (*Client) DeregisterAgent ¶
DeregisterAgent removes an agent from the central registry (POST /v1/agents/{id}/deregister), token-checked + idempotent server-side.
func (*Client) DetachWorkSession ¶
func (c *Client) DetachWorkSession(id, sid string) (work.DetailView, error)
DetachWorkSession moves a session to the item's history.
func (*Client) DialTunnel ¶
func (c *Client) DialTunnel(ctx context.Context, workerID, target string, networks ...string) (TunnelConn, error)
DialTunnel opens a worker TCP tunnel websocket.
func (*Client) DismissMergeSuggestion ¶
DismissMergeSuggestion is a person's no.
func (*Client) DismissWorkSuggestion ¶
func (c *Client) DismissWorkSuggestion(id, field string) (work.DetailView, error)
DismissWorkSuggestion drops a pending suggestion.
func (*Client) DispatchTodo ¶
func (c *Client) DispatchTodo(todoID string) (TodoDispatch, error)
DispatchTodo explicitly dispatches a todo's assignee (PLAN-02 P2), ignoring the item's status: the caller asked for it, so a `pending` or `done` item is a legitimate target. The server still requires an assignee and no live job.
func (*Client) ExportWorkflow ¶
ExportWorkflow fetches a workflow's reconstructed WorkflowSpec (GET /v1/workflows/{id}/export, T4.1). The server strips credential-looking values (SR403); the returned bool reports whether anything was redacted (from the X-Gofer-Redacted response header) so `workflow export` can warn that a placeholder must be filled in before re-running. An unknown id surfaces as a 404 error.
func (*Client) FlagScopedMemory ¶
func (c *Client) FlagScopedMemory(scope, scopeKey, key, reason, jobID string) (ScopedMemory, error)
FlagScopedMemory reports a scoped memory as out of date (reason required). jobID is informational: a job credential is recorded as its own job by the server.
func (*Client) GetDecision ¶
GetDecision fetches one decision (GET /v1/decisions/{id}); the read path applies lazy expiry, so a past-deadline decision comes back EXPIRED.
func (*Client) GetInteractions ¶
func (c *Client) GetInteractions(id string) ([]job.Interaction, error)
GetInteractions lists a job's running-time interactions (GET /v1/jobs/{id}/interactions), unwrapping the {"interactions":[...]} envelope. job.Interaction's JSON tags match the endpoint's element shape, so the slice decodes directly. Used by the mcp client backend (E28) to surface a peer job's pending/answered interactions. An unknown id surfaces as a 404 error.
func (*Client) GetJobDiffFull ¶
GetJobDiffFull fetches a job's captured diff as text (GET /v1/jobs/{id}/diff?full=1). The summary form lives on the job row (JobResult.DiffSummary); this is the PATCH, and a job that captured none is a 404 (an error here), because "the diff is missing" is worth saying rather than printing an empty screen.
func (*Client) GetJobRequest ¶
func (c *Client) GetJobRequest(id string) (job.JobRequest, error)
GetJobRequest fetches a job's ORIGINAL request, SECRET-STRIPPED (GET /v1/jobs/{id}/ request, P5: the endpoint now redacts by default — env values and secret-looking prompt/cmd become ***REDACTED***). It is for audit/display; it is NO LONGER used to re-submit (that moved server-side to RebuildJob). Unknown id / no request → error.
func (*Client) GetJobWorktree ¶
func (c *Client) GetJobWorktree(id string) (job.WorktreeStatus, error)
GetJobWorktree fetches the live state of a job's WT-01 managed worktree (branch, HEAD, commits ahead of the base, uncommitted changes, merged-into-base). A job without a managed worktree is a 404 from the server.
func (*Client) GetLogsTail ¶
GetLogsTail reads the last maxBytes of a job log stream (GET /v1/jobs/{id}/logs/{stream}?bytes=n). It is the byte-window counterpart of GetLogsWindow: callers that want a bounded tail of a report (the review screen) pick the window themselves instead of taking the 256KB default.
func (*Client) GetLogsWindow ¶
GetLogsWindow reads a log using a line window, or the legacy byte tail when Lines is zero.
func (*Client) GetPlanHandoff ¶
func (c *Client) GetPlanHandoff(id string, version int) (PlanHandoff, error)
func (*Client) GetSchedule ¶
GetSchedule fetches one schedule by id.
func (*Client) GetScopedMemory ¶
func (c *Client) GetScopedMemory(scope, scopeKey, key string) (ScopedMemory, error)
func (*Client) GetServerTZOffset ¶
GetServerTZOffset reads the server's local UTC offset in seconds (bd h-aii-tnua) from GET /v1/stats. ok=false means the server did not report it (an older build), which is what lets the CLI mark a fallback timestamp "(local)".
func (*Client) GetSession ¶
GetSession fetches one session with its recent turns.
func (*Client) GetTemplate ¶
func (c *Client) GetTemplate(projectKey, name string, vars map[string]string) (template.Preview, error)
GetTemplate reads ONE template plus the SERVER's render of it (vars are sent as repeated `var=k=v` query params). Rendering server-side is deliberate: it is the only side that can expand {{include: …}} and resolve {{head}} against the project the job would actually run in, so the preview equals the prompt a submit produces.
func (*Client) GetTunnelPreset ¶
func (c *Client) GetTunnelPreset(name string) (TunnelPreset, error)
GetTunnelPreset reads one preset. A missing name is a *StatusError with Status 404, which is what the local-fallback path branches on.
func (*Client) GetUsageStats ¶
func (c *Client) GetUsageStats() (StatsUsage, error)
GetUsageStats fetches the token/cost aggregate behind /v1/stats (SUP-01 E). It decodes that endpoint and keeps only the usage block — which is what `agent status` prints — so the dashboard can grow new blocks without touching this caller.
func (*Client) GetWorkItem ¶
func (c *Client) GetWorkItem(id string) (work.DetailView, error)
GetWorkItem reads one work item with its journal and sessions.
func (*Client) GetWorkerProjects ¶
func (c *Client) GetWorkerProjects(id string) (WorkerDetail, error)
func (*Client) GetWorkflow ¶
GetWorkflow fetches a workflow header + its step chain by id (GET /v1/workflows/{id}). An unknown id surfaces as a 404 error.
func (*Client) HeartbeatSession ¶
func (c *Client) HeartbeatSession(sid string, hb SessionHeartbeat) (AgentSession, error)
HeartbeatSession applies a hook event; the returned session's Relay is the switch the Stop hook keys on. A 404 error means the session is unknown.
func (*Client) HeartbeatTunnelForwarder ¶
func (c *Client) HeartbeatTunnelForwarder(id string, specs []TunnelSpecView) (TunnelForwarder, error)
HeartbeatTunnelForwarder renews a registration. specs may be nil to keep the rules the hub already holds.
func (*Client) ImportLocalTunnelPreset ¶
func (c *Client) ImportLocalTunnelPreset(name string) (TunnelPreset, error)
func (*Client) IssueGet ¶
func (c *Client) IssueGet(id, trackerID string) (IssueGetResp, error)
IssueGet reads one issue from the server's tracker mirror (read-only).
func (*Client) IssueList ¶
func (c *Client) IssueList(o IssueListOpts) (IssueListResp, error)
IssueList reads the server's tracker mirror (read-only).
func (*Client) LinkWork ¶
func (c *Client) LinkWork(id, kind, ref string) (work.DetailView, error)
LinkWork links an issue / plan / todo / job.
func (*Client) ListAgents ¶
ListAgents fetches the server's agents (GET /v1/agents) and returns them in the mcp bridge contract shape. It decodes the endpoint's agentView wire shape then folds version/error into a single Detail (mirroring the in-process mcpserver list-agents handler) so client mode and standalone mode surface an identical agent listing.
func (*Client) ListArtifacts ¶
func (c *Client) ListArtifacts(id string) (json.RawMessage, error)
ListArtifacts fetches a peer job's artifact manifest (GET /v1/jobs/{id}/artifacts) and returns the bare `[]ArtifactItem` array as raw JSON (the inner "artifacts" array, unwrapped from the {"artifacts":[...]} envelope). It is used by the peer-http runner to回传 the产物清单 metadata onto the host job (P4-b); the raw bytes flow straight into the jobs.artifacts_json column without re-marshalling, so the manifest round-trips byte-for-byte. An empty/absent manifest yields a nil slice (no error).
func (*Client) ListComments ¶
ListComments reads one object's thread (oldest first). The {"comments":[...]} envelope is unwrapped; an unknown scope/id surfaces as a 404 error.
func (*Client) ListDecisions ¶
ListDecisions queries GET /v1/decisions, optionally filtered by state and/or plan id ("" = no filter).
func (*Client) ListJobs ¶
ListJobs queries GET /v1/jobs with the given filters and returns the unwrapped job array (from the {"jobs":[...]} envelope). Empty filter fields are omitted from the query string. It reuses job.ListOpts (the same shape the server consumes) so the CLI (P2-c) and the server stay in lockstep; a zero-value opts lists every project's jobs up to the server default limit.
func (*Client) ListLocalTunnelPresets ¶
func (c *Client) ListLocalTunnelPresets() ([]TunnelPreset, error)
func (*Client) ListMemoryCandidates ¶
func (c *Client) ListMemoryCandidates(o MemoryCandidateListOpts) ([]jobstore.MemoryCandidate, error)
ListMemoryCandidates reads the knowledge candidates of delivered jobs.
func (*Client) ListMergeSuggestions ¶
func (c *Client) ListMergeSuggestions() ([]jobstore.WorkMergeSuggestion, error)
ListMergeSuggestions lists the pending merge suggestions.
func (*Client) ListPendingInteractions ¶
func (c *Client) ListPendingInteractions() ([]job.Interaction, error)
ListPendingInteractions fetches the pending interactions across all active jobs (E25 监督, GET /v1/interactions?status=pending), unwrapping the {"interactions":[...]} envelope. Used by the mcp client backend's gofer_list_pending_interactions tool (supervisor discovery in client mode).
func (*Client) ListPlanHandoffHistory ¶
func (c *Client) ListPlanHandoffHistory(id string) ([]PlanHandoff, error)
func (*Client) ListPlans ¶
func (c *Client) ListPlans(opts PlanListOpts) (PlanList, error)
ListPlans queries GET /v1/plans with the given filter/paging (F-d).
func (*Client) ListPresence ¶
ListPresence fetches the online registry (GET /v1/agents/presence), optionally filtered by role/project, unwrapping the {"agents":[...]} envelope. agent_token is never returned (presence.Agent has no token field).
func (*Client) ListProjects ¶
func (c *Client) ListProjects() ([]ProjectMeta, error)
ListProjects returns the server's live projects (GET /v1/meta → projects). It is the remote counterpart to reading the local config's projects, so a node (esp. a worker) can see what the SERVER has registered.
func (*Client) ListRetries ¶
ListRetries returns a job's durable retry chain, oldest attempt first. An unknown job is an error (the server 404s rather than reporting an empty chain).
func (*Client) ListRunners ¶
func (c *Client) ListRunners() ([]RunnerMeta, error)
ListRunners fetches the server's configured runners and their advertised capabilities (GET /v1/runners). The endpoint is read-only and uses the same runner rows consumed by the web console.
func (*Client) ListSchedules ¶
ListSchedules returns the unwrapped schedule array, optionally filtered by project key.
func (*Client) ListScopedMemories ¶
func (c *Client) ListScopedMemories(opts ScopedMemoryListOpts) ([]ScopedMemory, error)
func (*Client) ListSessionJobWatches ¶
func (c *Client) ListSessionJobWatches(sid string) ([]SessionJobWatch, error)
ListSessionJobWatches returns the session's currently pending job watches.
func (*Client) ListSessionMessages ¶
func (c *Client) ListSessionMessages(sid string) ([]SessionMessage, error)
func (*Client) ListSessionNudges ¶
func (c *Client) ListSessionNudges(sid string, all bool) ([]SessionNudge, error)
ListSessionNudges lists one session's nudges, or every session's when sid is "".
func (*Client) ListSessions ¶
func (c *Client) ListSessions(opts SessionListOpts) ([]AgentSession, error)
ListSessions lists agent sessions (GET /v1/sessions).
func (*Client) ListTemplates ¶
ListTemplates reads a project's task-book templates (SUP-01 P5): the project's own .gofer/templates first, then the server's global <config-dir>/templates. Templates live on the SERVER's disk, so a client (CLI/console) reads them over HTTP.
func (*Client) ListTunnelForwarders ¶
func (c *Client) ListTunnelForwarders() ([]TunnelForwarder, error)
ListTunnelForwarders lists the online forwarders.
func (*Client) ListTunnelPresets ¶
func (c *Client) ListTunnelPresets() ([]TunnelPreset, error)
ListTunnelPresets lists the server's presets.
func (*Client) ListTunnels ¶
func (c *Client) ListTunnels() ([]TunnelInfo, error)
ListTunnels lists active tunnels.
func (*Client) ListWakeups ¶
ListWakeups returns a job's wakeups, oldest first.
func (*Client) ListWorkItems ¶
func (c *Client) ListWorkItems(o WorkListOpts) (WorkList, error)
ListWorkItems lists work items.
func (*Client) ListWorkRequests ¶
func (c *Client) ListWorkRequests(id string, activeOnly bool, limit int) ([]jobstore.WorkRequest, error)
ListWorkRequests reads the request ledger of one item ("" = every item).
func (*Client) ListWorkers ¶
func (c *Client) ListWorkers() ([]WorkerMeta, error)
ListWorkers fetches the server's worker registry from GET /v1/meta. This includes configured workers even when they are currently disconnected.
func (*Client) ListWorkflowEvents ¶
func (c *Client) ListWorkflowEvents(id string, sinceSeq int64) ([]WorkflowEvent, error)
ListWorkflowEvents fetches a workflow's append-only lifecycle events (GET /v1/workflows/{id}/events, T4.3). sinceSeq>0 returns only events strictly after that cursor. The {"events":[...]} envelope is unwrapped to the bare slice.
func (*Client) ListWorkflowTemplates ¶
func (c *Client) ListWorkflowTemplates(name, project string) ([]workflow.WorkflowTemplate, error)
ListWorkflowTemplates lists (or, with name, shows) workflow templates; project, when set, also searches that project's .gofer/workflows.
func (*Client) ListWorkflows ¶
ListWorkflows queries GET /v1/workflows, optionally filtered by status, and returns the unwrapped header array (from the {"workflows":[...]} envelope).
func (*Client) LookupCurrentAgentSession ¶
func (c *Client) LookupCurrentAgentSession(getenv func(string) string, project string) SupervisorAutoBind
LookupCurrentAgentSession resolves the agent session the caller runs in from the environment and confirms it is a live registered session (one short GET per candidate; normally exactly one variable is set). project, when non-empty, must match the session's project — the server refuses a cross-project binding. A session on a worker / in a container binds too: a todo dispatched for another machine just does not claim it as its trusted source (job.dispatchTodo). Ownership is not visible to the client; the create call is the check.
func (*Client) MemoryFindings ¶
MemoryFindings reads GET /v1/memory-findings: the server-side memory doctor over the tracker mirror (open findings only unless all).
func (*Client) MergeJobWorktree ¶
MergeJobWorktree merges a local managed worktree branch into its main checkout; cleanupOthers also removes the sibling fan worktrees of the same workflow step.
func (*Client) MergeSuggest ¶
func (c *Client) MergeSuggest(targetID, sourceID, reason string) (jobstore.WorkMergeSuggestion, bool, error)
MergeSuggest records that source should merge into target (a person confirms it).
func (*Client) MergeWorkItems ¶
MergeWorkItems folds sources into the target item.
func (*Client) OpenSessionPermission ¶
func (c *Client) OpenSessionPermission(sid string, p SessionPermission) (Decision, error)
OpenSessionPermission opens a permission decision the hook then long-polls with WaitSessionTurn. 409 = the session does not wait for the web right now.
func (*Client) OpenSessionTurn ¶
OpenSessionTurn posts the agent's last message as a relay turn (hook Stop). A 409 error means relay is off.
func (*Client) OpenStream ¶
OpenStream issues a GET against /v1/jobs/{id}/stream under ctx, attaching the bearer token, and returns the live SSE response. The caller owns closing the body and parsing the SSE frames. Unlike the other helpers it streams (no per-request timeout) so a long-lived job stays connected; cancel via ctx.
It exists so a remote runner (internal/runner/peerhttp) can consume a peer's log stream without re-deriving the base URL / auth wiring.
func (*Client) PatchTodo ¶
func (c *Client) PatchTodo(todoID string, u TodoUpdate) (Todo, error)
PatchTodo applies one todo update and returns the stored item. status "" keeps the lifecycle, note nil keeps the note, and the patch only touches the fields it names. The dispatch fields flatten into the same body (todoPatch's json tags are the wire names), so one request carries both.
func (*Client) PatchWorkItem ¶
PatchWorkItem updates fields (PATCH body keys: rev, title, goal, status, status_source, blocker_kind, blocker_text, next_step, summary, project_key, workspace, priority, park_until, park_note, remind_at, unsorted). A stale rev answers 409.
func (*Client) PausePlan ¶
PausePlan holds a plan's automatic chain advance (POST /v1/plans/{id}/pause).
func (*Client) PickWorkflowFan ¶
PickWorkflowFan selects one completed fan of a join=pick workflow step.
func (*Client) PollInbox ¶
PollInbox polls an agent's inbox (POST /v1/agents/{id}/inbox/poll), unwrapping the {"messages":[...]} envelope. ack=false peeks without consuming (?ack=false). The agent_token is verified server-side (403 mismatch / 404 unknown surface as errors).
func (*Client) PostComment ¶
PostComment records a comment on scope/id (MCP-05 阶段 A) and returns the stored row plus whatever its @-mentions dispatched. WHO wrote it is the server's decision, taken from the credential the request authenticated with (SEC-01): a caller presenting a job's GOFER_JOB_TOKEN comments as that job's agent (recorded, dispatching only for a leader inside its own plan), anyone else comments as themselves.
func (*Client) PostMessage ¶
PostMessage delivers a message (POST /v1/messages) addressed by to (agent_id / role:<name> / role-one:<name> / broadcast) and returns the fan-out delivered count.
func (*Client) ProbeAgent ¶
func (c *Client) ProbeAgent(key, project string, timeoutSec int) (AgentProbe, error)
ProbeAgent submits a probe job for one agent on the server (SUP-01 P3): a synchronous, tagged job whose result is the agent's liveness. project names the project to run it in ("" = the server's first project admitting the agent); timeoutSec bounds it (0 = the server default).
func (*Client) PuntInteraction ¶
PuntInteraction POSTs to the punt endpoint (E28 client mode): the通用 sup marks a pending interaction as needs_human ("高危/拿不准, 留给人", y5wt). No body, no useful response — the central serve flips needs_human and leaves the interaction pending for a human. Returns the transport error only.
func (*Client) PutScopedMemory ¶
func (c *Client) PutScopedMemory(scope, scopeKey, key, content string, tags []string) (ScopedMemory, error)
func (*Client) PutStewardNotes ¶
func (c *Client) PutStewardNotes(body string, version int) (StewardNotesResp, error)
PutStewardNotes writes a new notes version when version is the current one (0 = the first write). A moved version returns *ErrStewardNotesConflict.
func (*Client) PutTunnelPreset ¶
func (c *Client) PutTunnelPreset(name string, p TunnelPreset, force bool) (TunnelPreset, error)
PutTunnelPreset writes one preset. Without force the server refuses to replace an existing name (409), which `tun save` surfaces as "use --force".
func (*Client) RebuildJob ¶
RebuildJob re-runs a job from its stored request + edits (P5). Empty overrides == a faithful re-run (the old `job rerun`); env stays server-side (only EnvSet/EnvUnset carry new values). Returns the NEW job's JobResult (its source_job_id links back to the source).
func (*Client) RedactJob ¶
func (c *Client) RedactJob(id string, req JobRedactRequest) (jobstore.RedactReport, error)
func (*Client) RedactJobSecrets ¶
func (c *Client) RedactJobSecrets(req JobSecretScanRequest) (jobstore.SecretBatchRedactReport, error)
func (*Client) RegisterAgent ¶
RegisterAgent registers/renews a driver agent with the central serve (POST /v1/agents/register) and returns its public address + private capability handle (E36 client mode). caller_id/client are stamped server-side from the bearer token + connection (provenance), so only name/role/project go over the wire.
func (*Client) RegisterSession ¶
func (c *Client) RegisterSession(in SessionRegister) (AgentSession, error)
RegisterSession upserts an agent session (hook SessionStart / first contact).
func (*Client) RegisterTunnelForwarder ¶
func (c *Client) RegisterTunnelForwarder(reg TunnelForwarderRegistration) (TunnelForwarder, error)
RegisterTunnelForwarder announces a forwarder and returns the stored registration (with the hub-assigned id).
func (*Client) RegisterWorker ¶
func (c *Client) RegisterWorker(id string, labels, projects []string) (WorkerRegistration, error)
func (*Client) RejectJob ¶
RejectJob POSTs to /v1/jobs/{id}/reject, recording a human's REFUSAL of a needs_review job: the job becomes rejected (terminal) and the note — required — is kept as the reason. resume continues the work: a new job is started with the note as its prompt and its id comes back in the outcome.
func (*Client) RejectMemoryCandidate ¶
func (c *Client) RejectMemoryCandidate(id int64) (jobstore.MemoryCandidate, error)
RejectMemoryCandidate marks candidate id rejected.
func (*Client) ReleaseSessionTakeover ¶
func (c *Client) ReleaseSessionTakeover(sid string) (AgentSession, error)
ReleaseSessionTakeover gives a taken-over session back to its terminal (POST /v1/sessions/{sid}/release-takeover, design §9.1 B): the server cancels the takeover job and returns the session to idle. 409 when the session is not handed off, 502 when the takeover job could not be stopped.
func (*Client) ReleaseSessionTurn ¶
ReleaseSessionTurn tells the server the hook's fresh idle reading while it blocks on an auto-armed turn: released=true means the human is back, the turn is closed (EXPIRED + released_by=user_returned) and the hook must let the agent stop. A false return (still away, explicit relay, turn already settled) leaves the wait running.
func (*Client) ReloadWorker ¶
ReloadWorker asks the server to make one worker re-read its config and WAITS for the worker's receipt (POST /v1/workers/{id}/reload). A worker that refuses the new config comes back as a non-2xx whose error text carries the worker's OWN reason (errorFor keeps the server's {error,detail} verbatim) — the caller must print it as-is: it names the thing to fix.
wait is the server-side budget (0 = the server default). The HTTP timeout is set a little wider so the server's own timeout answer (504, with context) wins the race against a client-side abort, which would say nothing useful.
func (*Client) RemoveJobWorktree ¶
RemoveJobWorktree runs `git worktree remove` for a job's managed worktree on the machine serving the request. A worktree with uncommitted changes is refused (409) unless force is set; deleteBranch also deletes the branch (the deliverable, so it is opt-in). The returned status has Exists=false on success.
func (*Client) RemoveSessionJobWatch ¶
RemoveSessionJobWatch removes a pending completion watch.
func (*Client) RemoveWorker ¶
func (*Client) RenameTrackerRepo ¶
func (c *Client) RenameTrackerRepo(oldID, newID string) (TrackerRenameResult, error)
RenameTrackerRepo asks the server to move a mirrored repository from a legacy UUID tracker_id to its derived short id (POST /v1/tracker/repos/{tracker_id}/rename).
DEPRECATED(v0.126): remove in v0.129 (legacy UUID tracker_id migration).
func (*Client) ReportWork ¶
ReportWork writes a session's self-report (goal/status/blocker/next/summary).
func (*Client) RequestWorkReport ¶
func (c *Client) RequestWorkReport(id, sessionID, kind string) (bool, []WorkReportRequestResult, error)
RequestWorkReport asks the item's running session(s) to report (kind "report", the default) or to write a hand-over ("handoff") through the request ledger; a session that is not running is tidied up instead.
func (*Client) ResolveSessionPermission ¶
ResolveSessionPermission reports that the prompt of tool call fp ("" = every pending prompt) was settled in the terminal; it returns how many were closed.
func (*Client) ResumeJob ¶
ResumeJob POSTs to /v1/jobs/{id}/resume to续接 the source job's底层 agent 会话 (session-capture P2). It returns the NEW job's snapshot (its session_id links back to the source session). runner is optional; when set the server enforces it equals the source runner (同 runner 约束). The default is async — the caller watches the returned job id.
func (*Client) ResumeJobWith ¶
func (c *Client) ResumeJobWith(id, prompt, runner string, opts job.ResumeOptions) (job.JobResult, error)
ResumeJobWith is ResumeJob with an explicit continuation form (opts.Mode: session|interactive|batch) and/or target agent (opts.Agent, same session family only). Zero opts behave exactly like ResumeJob.
func (*Client) ResumePlan ¶
ResumePlan releases a plan's pause and block and advances the chain (POST /v1/plans/{id}/resume).
func (*Client) ResumeSession ¶
func (c *Client) ResumeSession(sid, input string) (SessionDeliverResult, error)
ResumeSession wakes a session up (POST /v1/sessions/{sid}/resume): the server starts an interactive `--resume` process for it — an ended session included — and the answer names the job to attach to. input is optional first text for the new terminal. A 409 carries the reason code and a plain explanation.
func (*Client) RotateScheduleToken ¶
RotateScheduleToken mints a fresh webhook secret for a schedule (AUTO-02b, POST /v1/schedules/{id}/rotate-token). It also ENABLES the webhook for a schedule that was created without one; the previous token stops working at once.
func (*Client) RuleList ¶
RuleList lists the library (GET /v1/rules). The server always answers with an array, but a null body is normalised to an empty slice so a caller may range and len() without a nil check.
func (*Client) RuleRemove ¶
RuleRemove deletes a rule (DELETE /v1/rules/{name}, 204).
func (*Client) RuleSet ¶
RuleSet creates or replaces a rule (PUT /v1/rules/{name}) with the text as the JSON `content` field. A rule is small by design (server.rules_max_bytes), so the body is buffered rather than streamed.
func (*Client) RunPlan ¶
RunPlan starts a plan's chain (POST /v1/plans/{id}/run, PLAN-03): it releases a pause and a block, queues every pending item whose dependencies are satisfied and that has an assignee, and returns the plan header as it stands.
func (*Client) RunSchedule ¶
RunSchedule triggers a schedule immediately without changing its next_run_at.
func (*Client) RunnersOverview ¶
func (c *Client) RunnersOverview() (RunnersOverview, error)
RunnersOverview fetches the runners together with the server's version.
func (*Client) SaySession ¶
SaySession answers the session's newest OPEN turn. A 409 error means no turn is waiting.
func (*Client) ScanJobSecrets ¶
func (c *Client) ScanJobSecrets(req JobSecretScanRequest) (jobstore.SecretScanReport, error)
func (*Client) SendSessionMessage ¶
func (c *Client) SendSessionMessage(sid, message string) (SessionMessage, error)
SendSessionMessage submits a web message. The server chooses relay for a waiting turn or a one-shot messenger job for every other session state.
func (*Client) SessionAsk ¶
SessionAsk "带话": delivers a short message to a running session (terminal session id or ACP / pty session job id). A session that is not online is a 409 error.
func (*Client) SessionTail ¶
SessionTail reads the read-only tail of a session's transcript.
func (*Client) SessionTakeoverPlan ¶
func (c *Client) SessionTakeoverPlan(sid string) (SessionResumePlan, error)
SessionTakeoverPlan asks what waking the session up would do, without doing it.
func (*Client) SetJobTitle ¶
SetJobTitle updates or clears a job's human-readable title.
func (*Client) SetPlanHandoff ¶
func (c *Client) SetPlanHandoff(id, body string, expectedVersion int) (PlanHandoff, error)
func (*Client) SetPlanLeader ¶
SetPlanLeader flips a plan's leader-round switch (PATCH /v1/plans/{id}, LEAD-02) without touching its status: on|off. The returned plan carries the switch's new value and, when it was just turned on, the warnings about the members still in flight.
func (*Client) SetPlanSupervisorSessionID ¶
SetPlanSupervisorSessionID binds or clears the supervising session. A nil pointer preserves the current binding; a pointer to empty string clears it.
func (*Client) SetScheduleEnabled ¶
SetScheduleEnabled toggles a schedule through /enable or /disable.
func (*Client) SetSessionNudgeState ¶
func (c *Client) SetSessionNudgeState(id, state string) (SessionNudge, error)
SetSessionNudgeState pauses ("paused") or resumes ("active") a nudge.
func (*Client) SetSessionRelayMode ¶
func (c *Client) SetSessionRelayMode(sid, mode string) (AgentSession, error)
SetSessionRelayMode sets the three-state relay switch (auto|on|off, R1).
func (*Client) SetWakeupEnabled ¶
SetWakeupEnabled flips a wakeup's switch (PATCH /v1/wakeups/{id}). Enabling a timer re-arms it from now — the ticks it missed while off are not replayed.
func (*Client) SkillExport ¶
SkillExport streams a skill's archive (GET /v1/skills/{name}/export) into w.
It streams rather than buffering for the same reason XferDownload does — the payload is a file the caller owns — and w is written as given: the caller owns the temp-name + rename policy, so a failed stream never leaves a usable-looking .zip behind.
func (*Client) SkillImportFile ¶
func (c *Client) SkillImportFile(path string) (SkillImportResult, error)
SkillImportFile uploads a local .zip as the multipart `file` part (POST /v1/skills/import). The CLI zips a local DIRECTORY into a temp .zip first: the wire carries an archive, never a client-side path, so the server never has to reach back into this machine's filesystem.
func (*Client) SkillImportSource ¶
func (c *Client) SkillImportSource(src string) (SkillImportResult, error)
SkillImportSource imports from a spec the SERVER resolves itself (`http(s)://…/x.zip`, `git+https://…#subdir`) via POST /v1/skills/import with a JSON body. Those sources are fetched server-side on purpose: a client node has no reason to download an archive it would only hand straight back.
func (*Client) SkillList ¶
SkillList lists the library (GET /v1/skills). The server always answers with an array, but a null body is normalised to an empty slice so a caller may range and len() without a nil check.
func (*Client) SkillRemove ¶
SkillRemove deletes a skill (DELETE /v1/skills/{name}, 204).
func (*Client) SkillShow ¶
SkillShow fetches one skill together with its SKILL.md text (GET /v1/skills/{name}).
func (*Client) SkillUpdate ¶
func (c *Client) SkillUpdate(name string) (SkillUpdateResult, error)
SkillUpdate re-fetches a skill from its recorded source (POST /v1/skills/{name}/update).
func (*Client) SplitWorkItem ¶
func (c *Client) SplitWorkItem(id, title, goal string, sessionIDs []string, keep bool) (WorkSplitResult, error)
SplitWorkItem creates a new item out of id.
func (*Client) StageWorkerUpgrade ¶
StageWorkerUpgrade uploads the file as worker id's upgrade binary. The server computes the digest itself; the returned values are what it stored.
func (*Client) StartHostedTunnelForwarder ¶
func (c *Client) StartHostedTunnelForwarder(name string) (TunnelForwarder, string, error)
StartHostedTunnelForwarder starts a server-local listener for one preset.
func (*Client) StartWorkerUpgrade ¶
func (c *Client) StartWorkerUpgrade(id string, opt WorkerUpgradeOptions) (WorkerUpgradeRecord, error)
StartWorkerUpgrade asks the server to upgrade worker id. It returns once the worker has accepted the new binary (HTTP 202) with the pending upgrade record; the final outcome is read from GetWorker(id).Upgrade.
func (*Client) StatsBackfill ¶
func (c *Client) StatsBackfill(req StatsBackfillRequest) (StatsBackfillResult, error)
StatsBackfill runs one dashboard-metrics backfill batch on the server.
func (*Client) StewardAsk ¶
StewardAsk puts a question to the steward (starting it when needed).
func (*Client) StewardNotes ¶
func (c *Client) StewardNotes(version int) (StewardNotesResp, error)
StewardNotes reads the latest notes (version 0) or one historical version.
func (*Client) StewardNotesHistory ¶
StewardNotesHistory lists every version, newest first.
func (*Client) StewardRestart ¶
func (c *Client) StewardRestart() (steward.StartResult, error)
StewardRestart ends the session and opens a fresh one from the prime.
func (*Client) StewardReview ¶
func (c *Client) StewardReview(force bool) (steward.ReviewResult, error)
StewardReview runs a manual review now (force = even when nothing changed).
func (*Client) StewardReviewSummary ¶
StewardReviewSummary stores the review's point of view (the digest's steward comment).
func (*Client) StewardStart ¶
func (c *Client) StewardStart() (steward.StartResult, error)
StewardStart opens the steward session when none lives.
func (*Client) StewardStatus ¶
func (c *Client) StewardStatus() (StewardState, error)
StewardStatus reads the steward's status and settings.
func (*Client) StewardStop ¶
StewardStop ends the live session; stopped=false when none lived.
func (*Client) StopHostedTunnelForwarder ¶
StopHostedTunnelForwarder stops a server-local listener for one preset.
func (*Client) StopTunnelForwarder ¶
func (c *Client) StopTunnelForwarder(id string) (TunnelForwarder, error)
StopTunnelForwarder asks an external forwarder process to exit. The hub answers 202 with the marked entry; the process exits at its next heartbeat (<= 30s). A 409 means the process is too old to be stopped remotely (or is server-hosted).
func (*Client) StreamJob ¶
StreamJob opens the job's SSE stream (GET /v1/jobs/{id}/stream?from=) under ctx and invokes onEvent for each parsed frame in order. It returns when the stream emits an `end` event, the connection closes (EOF), or ctx is cancelled. The from offset resumes the stdout stream from a byte position (<=0 starts at the beginning). It reuses ParseSSE (the same Go-side frame parser the peer-http runner consumes), buffering across reads so a frame split over two reads is still parsed once whole. A transport error other than EOF is returned; ctx cancellation returns nil (a clean caller-driven stop).
func (*Client) SubmitJob ¶
SubmitJob POSTs a JobRequest to /v1/jobs and returns the initial JobResult (with the assigned id and queued/running status). It ignores the 202/async distinction; use SubmitJobSync when that matters.
func (*Client) SubmitJobSync ¶
func (c *Client) SubmitJobSync(req job.JobRequest) (SubmitResult, error)
SubmitJobSync POSTs a JobRequest as JSON and reports whether the server fell back to async (202 + X-Gofer-Async) so a sync caller can switch to polling.
func (*Client) SubmitMarkdown ¶
func (c *Client) SubmitMarkdown(body []byte) (SubmitResult, error)
SubmitMarkdown POSTs a md+yaml document (frontmatter + prose) to /v1/jobs with Content-Type text/markdown so the server parses it into a JobRequest (design §6.2). Like SubmitJobSync it surfaces the 202/async fallback.
func (*Client) SubmitWorkflow ¶
SubmitWorkflow POSTs a WorkflowSpec as JSON to /v1/workflows and returns the created workflow header (running, step 1 started). The caller id is stamped server-side, so the spec carries no caller field (design §5.7).
func (*Client) SubmitWorkflowTemplate ¶
SubmitWorkflowTemplate asks the server to resolve a named workflow template.
func (*Client) SuggestMemory ¶
func (c *Client) SuggestMemory(in today.MemorySuggestInput) (today.MemorySuggestion, bool, error)
SuggestMemory records a memory cleanup suggestion (POST /v1/memory-suggestions).
func (*Client) SummarizeWork ¶
func (c *Client) SummarizeWork(id string) (jobstore.WorkRequest, error)
SummarizeWork triggers a tidy-up of the item now; it returns the ledger request that tracks it (the run is in the background).
func (*Client) SyncTrackerRepo ¶
func (c *Client) SyncTrackerRepo(trackerID string) (TrackerRepoSyncResult, error)
SyncTrackerRepo asks the server to run `gofer repo sync` in the mirrored repository trackerID (POST /v1/tracker/repos/{tracker_id}/sync; person credentials only).
func (*Client) TodayAdvise ¶
TodayAdvise writes the steward's (or a person's) advice on one 「今天」 card.
func (*Client) UnflagScopedMemory ¶
func (c *Client) UnflagScopedMemory(scope, scopeKey, key string) (ScopedMemory, error)
UnflagScopedMemory clears every flag of a scoped memory (the human review).
func (*Client) UnlinkWork ¶
func (c *Client) UnlinkWork(id, kind, ref string) (work.DetailView, error)
UnlinkWork removes a link.
func (*Client) UnregisterTunnelForwarder ¶
UnregisterTunnelForwarder removes a registration (the forwarder's clean goodbye).
func (*Client) UpdatePlan ¶
UpdatePlan moves a plan along its lifecycle (PATCH /v1/plans/{id}, P6). status must be one of open/done/archived/blocked. A nil progress keeps the plan's current progress.
func (*Client) UpdatePlanTags ¶
UpdatePlanTags updates the plan's complete tag set and/or removes named tags.
func (*Client) UpdateTodo ¶
UpdateTodo sets a todo's manual done flag (legacy二态 wrapper over PatchTodo).
func (*Client) WaitSessionTurn ¶
func (c *Client) WaitSessionTurn(sid, decisionID string, waitSec int) (TurnStatus, error)
WaitSessionTurn long-polls a turn for up to waitSec seconds (server caps at 25).
func (*Client) WatchJob ¶
func (c *Client) WatchJob(ctx context.Context, id string, from int, h WatchHandlers) (final string, err error)
WatchJob streams a job's SSE (status + incremental logs) under ctx until the stream ends (terminal `end` frame / EOF) or ctx is cancelled, invoking the handlers on status changes and log text. It returns the terminal status it observed; when the stream ended without a terminal status frame it fetches the authoritative status via GetJob (final == "" only if that fetch also fails). ctx cancellation (e.g. Ctrl-C) returns the status seen so far (often ""), so the caller can detect an interrupt via ctx.Err(). The state-machine is the shared watch logic behind `job watch` and `job rerun --watch`.
func (*Client) WatchWorkflow ¶
func (c *Client) WatchWorkflow(ctx context.Context, id string, onStep func(st WorkflowStep)) (Workflow, error)
WatchWorkflow polls GetWorkflow until the workflow reaches a terminal state, invoking onStep on each step's status CHANGE (per step index). It returns the terminal workflow. Workflow-level SSE is a follow-up; v1 uses a simple poll loop (plan §P3-a range note). onStep may be nil.
func (*Client) WorkDigest ¶
WorkDigest previews the digest, or with send queues it to the webhooks now.
func (*Client) WorkSummarizerStatus ¶
WorkSummarizerStatus reads the summarizer's availability and the effective work settings as raw JSON (the console's shape).
func (*Client) WorkToTodo ¶
func (c *Client) WorkToTodo(id, planID, newPlanTitle string) (WorkToTodoResult, error)
WorkToTodo turns the item into a todo of planID (empty = a new plan titled newPlanTitle, default the item's title). A second conversion is a 409 error.
func (*Client) WorkerAssignable ¶
func (c *Client) WorkerAssignable(workerID string) (WorkerAssignable, error)
WorkerAssignable fetches GET /v1/workers/{id}/assignable — the read-only call `gofer worker init` makes before it can infer roots or probe agents. The endpoint requires a user caller or the worker's own token; a worker init runs with the latter (the token it is being handed).
func (*Client) XferDownload ¶
XferDownload streams a transfer's payload into destPath (GET /v1/xfer/{id}/content) and returns the bytes written plus their sha256.
The bytes are verified twice on the way in: the declared size against X-Gofer-Size, and the streaming digest against X-Gofer-Sha256. Anything that does not match — or a write error — REMOVES the file, so a caller never sees a truncated or corrupted payload it might mistake for the real one.
destPath is written as given: the caller owns the temp-name + rename policy (the CLI downloads to `<dst>.gofer-part` and renames), because only the caller knows what "never leave a partial file" means for its destination.
func (*Client) XferGet ¶
XferGet asks a runner to read project/path and stage it for us (POST /v1/xfer with a JSON meta, no payload). The returned record is dispatched already: poll XferStatus until it is done, then XferDownload the content.
func (*Client) XferList ¶
func (c *Client) XferList(state, runner string) ([]XferRecord, error)
XferList lists the staging area (GET /v1/xfer?state=&runner=), newest first as the server orders it. Empty filters are omitted.
func (*Client) XferPrecheck ¶
func (c *Client) XferPrecheck(ctx context.Context, runner, project, path string, size int64, force bool) error
XferPrecheck asks the server to validate a transfer target and size WITHOUT staging anything or sending a payload (bd h-aii-gnm3). xferPut calls it after the stat and BEFORE the digest pass, so an escaping path, an unknown project, an offline runner or an over-cap file fails while the file is still untouched — the alternative (found on a real machine) was a 400 after 34% of the bytes had been uploaded.
It carries the same meta object the multipart create sends, so the two can never validate different things.
func (*Client) XferPut ¶
func (c *Client) XferPut(ctx context.Context, runner, project, path, localPath string, force bool, progress func(sent, total int64)) (XferRecord, error)
XferPut pushes a local file to runner:project/path (POST /v1/xfer, multipart/form-data). The file is stat'ed and hashed first — the server verifies the DECLARED digest against the streamed one, so the meta field has to carry the real sha256 — then streamed in 1MB chunks, which is what lets progress fire and keeps the bytes off the heap. progress, when set, is called after every chunk with the bytes sent so far and the total.
force allows replacing a file that already exists at the target (without it a push onto an existing path fails with the server's own "exists").
The returned record is the meta we sent plus the created id and state: the create answer carries nothing else.
func (*Client) XferRemove ¶
XferRemove deletes a transfer and its staged payload (DELETE /v1/xfer/{id}).
func (*Client) XferStage ¶
func (c *Client) XferStage(ctx context.Context, runner, project, path, localPath string) (XferRecord, error)
XferStage pushes a local file into the staging area and STOPS there (no executor is dispatched): it is the `job run --upload` half of XFER-01 X2, where the file is placed by the job's executing machine — at the job's own cwd — once the job starts. The returned id goes into the request's uploads.
func (*Client) XferStatus ¶
func (c *Client) XferStatus(id string) (XferRecord, error)
XferStatus fetches one transfer's current record (GET /v1/xfer/{id}).
type Comment ¶
type Comment struct {
ID string `json:"id"`
Scope string `json:"scope"`
ScopeID string `json:"scope_id"`
Author string `json:"author"`
AuthorKind string `json:"author_kind"`
Body string `json:"body"`
Mentions []string `json:"mentions"`
CreatedAt int64 `json:"created_at"`
// TriggeredJobID is the job this comment dispatched ("" = none).
TriggeredJobID string `json:"triggered_job_id,omitempty"`
// Dispatched is the per-mention receipt, present on the POST response.
Dispatched []CommentDispatch `json:"dispatched,omitempty"`
}
Comment is one comment on the wire (MCP-05 阶段 A): a row of a job's, a plan's or a checklist item's thread. Mentions is the parsed @-name list (so a client highlights without re-parsing the body), TriggeredJobID the first job the comment started, and Dispatched the full set when one comment mentioned several agents.
type CommentDispatch ¶
type CommentDispatch struct {
Mention string `json:"mention"`
Kind string `json:"kind"`
JobID string `json:"job_id"`
}
CommentDispatch is one job an @-mention started.
type CreateScheduleRequest ¶
type CreateScheduleRequest struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Cron string `json:"cron"`
DelaySec int64 `json:"delay_sec,omitempty"`
RunAt int64 `json:"run_at,omitempty"`
Request job.JobRequest `json:"request"`
Enabled *bool `json:"enabled,omitempty"`
CatchUp *bool `json:"catch_up,omitempty"`
// Webhook enables the schedule's external trigger endpoint (AUTO-02b): the server
// mints a trigger_token, shown on the schedule from then on.
Webhook bool `json:"webhook,omitempty"`
}
CreateScheduleRequest is POST /v1/schedules. Enabled/CatchUp are pointers so callers can omit them and let the server defaults apply.
type Decision ¶
type Decision struct {
ID string `json:"id"`
PlanID string `json:"plan_id,omitempty"`
Title string `json:"title"`
Question string `json:"question"`
Options []string `json:"options,omitempty"`
Answer string `json:"answer,omitempty"`
State string `json:"state"`
TimeoutSec int64 `json:"timeout_sec"`
AskedAt int64 `json:"asked_at"`
AnsweredAt int64 `json:"answered_at,omitempty"`
AnsweredBy string `json:"answered_by,omitempty"`
// SessionID / Kind identify a session-relay turn (SESS-01); empty otherwise.
SessionID string `json:"session_id,omitempty"`
Kind string `json:"kind,omitempty"`
// ReleasedBy is set when a relay turn was closed without an answer (SR-A5,
// "user_returned"): the hook saw the human come back. Empty otherwise.
ReleasedBy string `json:"released_by,omitempty"`
// Detail is the JSON audit blob of a NON-turn delivery (SESS-01 §9.1 A):
// {"path":"tmux","job_id":"…"} when the relay typed the text into a terminal
// instead of answering a turn. Empty for real turns.
Detail string `json:"detail,omitempty"`
}
Decision is the client-side view of a plan_decisions row (decision channel, Part C §C3). PlanID "" is a global question; Options empty = free-text answer. State is OPEN|ANSWERED|EXPIRED; timestamps are unix seconds.
type ErrStewardNotesConflict ¶
ErrStewardNotesConflict is returned by PutStewardNotes when the version moved; Current carries the latest notes.
func (*ErrStewardNotesConflict) Error ¶
func (e *ErrStewardNotesConflict) Error() string
type IssueBrief ¶
type IssueBrief struct {
TrackerID string `json:"tracker_id"`
ProjectKey string `json:"project_key,omitempty"`
ID string `json:"id"`
Title string `json:"title"`
Type string `json:"type,omitempty"`
Status string `json:"status"`
Priority int `json:"priority"`
Assignee string `json:"assignee,omitempty"`
Tags []string `json:"tags,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
}
IssueBrief is one row of the read-only issue list (GET /v1/issues).
type IssueGetResp ¶
type IssueGetResp struct {
TrackerID string `json:"tracker_id"`
Issue map[string]any `json:"issue"`
}
IssueGetResp is one issue in full plus the repo it came from.
type IssueListOpts ¶
type IssueListOpts struct {
Project, TrackerID, Repo, Status, Type, Query string
Tags []string
Limit int
}
IssueListOpts filters IssueList.
type IssueListResp ¶
type IssueListResp struct {
Issues []IssueBrief `json:"issues"`
Total int `json:"total"`
Truncated bool `json:"truncated"`
}
IssueListResp is the issue list with the unfiltered-by-limit total.
type JobRedactRequest ¶
type JobSecretScanRequest ¶
type JobSecretScanRequest struct {
Literals []string `json:"literals,omitempty"`
Patterns []string `json:"patterns,omitempty"`
Project string `json:"project,omitempty"`
Since int64 `json:"since,omitempty"`
Redact bool `json:"redact,omitempty"`
Yes bool `json:"yes,omitempty"`
Vacuum bool `json:"vacuum,omitempty"`
}
type MemoryCandidateListOpts ¶
MemoryCandidateListOpts filters GET /v1/memory-candidates (gofer-3nxa.2). Status "" = pending, "all" = every state.
type Meta ¶
type Meta struct {
Projects []ProjectMeta `json:"projects"`
Agents []MetaAgent `json:"agents"`
Runners []MetaRunner `json:"runners"`
}
Meta is the server's read-only form-options aggregate (GET /v1/meta): the one authed round trip a config-less client node needs to answer what the server has.
type MetaAgent ¶
type MetaAgent struct {
Key string `json:"key"`
Type string `json:"type"`
Batch bool `json:"batch"`
Interactive bool `json:"interactive,omitempty"`
}
MetaAgent is one agent from the server's /v1/meta aggregate: its key/type plus the AGT-02 capability bits (batch = submittable as a plain job, interactive = has an interactive argv). Unlike AgentMeta (/v1/agents) it carries no availability probe — /v1/meta answers what is DEFINED, which is what a client node's `agent list` shows.
type MetaRunner ¶
type MetaRunner struct {
Name string `json:"name"`
Type string `json:"type"`
WorkerID string `json:"worker_id,omitempty"`
}
MetaRunner is one runner row from /v1/meta (name + type, plus the worker id a worker runner is pinned to in the server config).
type PermissionSuggestionLabel ¶
type PermissionSuggestionLabel struct {
Label string `json:"label"`
}
PermissionSuggestionLabel is one "always allow" choice of a permission prompt (only its human label travels to the server).
type Plan ¶
type Plan struct {
PlanID string `json:"plan_id"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
Owner string `json:"owner,omitempty"`
Progress int `json:"progress,omitempty"`
// Project is the project this plan's todos are dispatched into (PLAN-02 P2).
Project string `json:"project,omitempty"`
SupervisorSessionID string `json:"supervisor_session_id,omitempty"`
// Paused holds the chain advance (PLAN-03); BlockedTodo is the item a failed chain
// job parked the plan on.
Paused bool `json:"paused,omitempty"`
BlockedTodo string `json:"blocked_todo,omitempty"`
// Leader is this plan's leader-round switch (LEAD-02): on|off, `off` by default.
Leader string `json:"leader,omitempty"`
Tags []string `json:"tags,omitempty"`
// Warnings carries what a write could not refuse outright — today the "N running
// job(s) will wake the leader when they finish" note a leader-on PATCH returns.
Warnings []string `json:"warnings,omitempty"`
// LeaderRound is the plan's round state, present while `leader` is on.
LeaderRound *PlanLeaderRound `json:"leader_round,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
Counts *jobstore.PlanCounts `json:"counts,omitempty"`
TodoCounts *jobstore.PlanTodoCounts `json:"todo_counts,omitempty"`
Completion *jobstore.PlanCompletion `json:"completion,omitempty"`
Usage *PlanUsage `json:"usage,omitempty"`
Jobs []job.JobResult `json:"jobs,omitempty"`
Todos []Todo `json:"todos,omitempty"`
Decisions []Decision `json:"decisions,omitempty"`
}
Plan is the client-side view of a plan header. GetPlan inlines its jobs, todos and decisions.
type PlanHandoff ¶
type PlanLeaderRound ¶
type PlanLeaderRound struct {
Round int `json:"round"`
MaxRounds int `json:"max_rounds"`
LastJobID string `json:"last_job_id,omitempty"`
Active bool `json:"active"`
}
PlanLeaderRound is a plan's leader-round state (LEAD-02): the rounds already spent, the configured cap and the most recent leader job. Active says the GLOBAL master switch is on — a plan can be switched on while no round will actually fire.
type PlanList ¶
type PlanList struct {
Plans []Plan `json:"plans"`
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
PlanList is one page of plans plus the paging facts around it: Total is how many plans match the filter (not how many came back), Limit/Offset are the page the server actually served (its default when the caller named none, its cap when the caller asked for more).
type PlanListOpts ¶
type PlanListOpts struct {
Status string
Project string
// Q matches a plan id by prefix or a title by substring, case-insensitively.
Q string
Tags []string
Limit int
Offset int
}
PlanListOpts are the filter/paging knobs GET /v1/plans accepts (F-d). The zero value asks for the server's default page: every plan, newest first, 20 rows.
type PlanSessionUsage ¶
type PlanSessionUsage struct {
Main runner.Usage `json:"main"`
Sub runner.Usage `json:"sub"`
Total runner.Usage `json:"total"`
ByModel map[string]runner.Usage `json:"by_model,omitempty"`
Sessions int `json:"sessions"`
}
PlanSessionUsage is the bound supervising session's usage booked on a plan.
type PlanUsage ¶
type PlanUsage struct {
Jobs int `json:"jobs"`
TotalTokens int64 `json:"total_tokens"`
CostUSD float64 `json:"cost_usd"`
ByAgent map[string]UsageAgent `json:"by_agent"`
// Session is the supervising session's usage attributed to the plan (nil = none).
Session *PlanSessionUsage `json:"session,omitempty"`
// Overall is jobs + session.
Overall struct {
TotalTokens int64 `json:"total_tokens"`
CostUSD float64 `json:"cost_usd"`
} `json:"overall"`
}
PlanUsage is the plan's token/cost roll-up (PLAN-02 P2): every attached job counts in Jobs; only the ones that reported numbers move the sums. ByAgent is keyed by agent and reuses UsageAgent — the same tally the dashboard's usage card shows.
type ProjectMeta ¶
type ProjectMeta struct {
Key string `json:"key"`
AllowedAgents []string `json:"allowed_agents,omitempty"`
AllowedRunners []string `json:"allowed_runners,omitempty"`
DefaultAgent string `json:"default_agent,omitempty"`
// AllowInteractive / AllowExec mirror the server's admission gates that are
// independent of the allowlists (web console parity); WorkerOnly marks a project
// that exists ONLY on an online worker (no host config), which is why it has no
// host_path and carries empty allowlists.
AllowInteractive bool `json:"allow_interactive"`
AllowExec bool `json:"allow_exec"`
WorkerOnly bool `json:"worker_only,omitempty"`
// Injected marks the server's built-in `default` project (not declared in config).
Injected bool `json:"injected,omitempty"`
// HostPath / ContainerPath are the project's two path views (additive meta
// fields); a client node matches its cwd against both.
HostPath string `json:"host_path,omitempty"`
ContainerPath string `json:"container_path,omitempty"`
}
ProjectMeta is one project as the server exposes it via /v1/meta (key + allowlists + default agent). It carries no host_path (that is a server-side filesystem path; the meta endpoint omits it). Used by `project list --remote` (E38②) and shared with the mcp client mode / worker init (E28/E37), plus the client-mode `project show/validate` (C2).
type RetriesResp ¶
RetriesResp is the `{job_id, retries: [...]}` envelope of the list endpoint.
type Retry ¶
type Retry struct {
ID string `json:"id"`
SourceJobID string `json:"source_job_id"`
Attempt int `json:"attempt"`
MaxAttempts int `json:"max_attempts,omitempty"`
Reason string `json:"reason"`
NextRunAt int64 `json:"next_run_at"`
LeaseUntil int64 `json:"lease_until,omitempty"`
State string `json:"state"`
NewJobID string `json:"new_job_id,omitempty"`
CreatedAt int64 `json:"created_at"`
}
Retry is the client-side view of one AUTO-03 durable retry row (design §二.3): the scheduled re-run of a FAILED job, which a hub-side sweeper submits when NextRunAt arrives (so it survives a server restart). Timestamps are unix SECONDS.
State is one of pending|claimed|done|cancelled: claimed means a sweeper holds the row right now (LeaseUntil is its lease), done means it was submitted as NewJobID. MaxAttempts is the attempt ceiling the row itself was scheduled under — 0 when the row carries no policy, and then the attempt has no `/M`.
type RuleView ¶
type RuleView struct {
rule.Rule
// Content is the stored file verbatim (frontmatter included).
Content string `json:"content,omitempty"`
}
RuleView is one rule as GET /v1/rules/{name} returns it: the index metadata plus the rule text, so `show` needs one request rather than two.
type RunnerAgentMeta ¶
type RunnerAgentMeta struct {
Key string `json:"key"`
Type string `json:"type,omitempty"`
Interactive bool `json:"interactive,omitempty"`
Available *bool `json:"available,omitempty"`
Version string `json:"version,omitempty"`
}
RunnerAgentMeta is the typed agent capability advertised by a runner in GET /v1/runners. Available is a pointer because older workers may omit the probe field entirely; nil means unknown rather than unavailable.
type RunnerCapabilities ¶
type RunnerCapabilities struct {
Projects []string `json:"projects,omitempty"`
AgentCaps []RunnerAgentMeta `json:"agent_caps,omitempty"`
}
RunnerCapabilities is the project and agent set a runner reports.
type RunnerMeta ¶
type RunnerMeta struct {
Name string `json:"name"`
Type string `json:"type"`
Status string `json:"status"`
Capabilities *RunnerCapabilities `json:"capabilities,omitempty"`
// Worker is the connection detail of a worker row (nil on other rows).
Worker *RunnerWorkerBrief `json:"worker,omitempty"`
}
RunnerMeta is one row returned by GET /v1/runners.
type RunnerServer ¶
type RunnerServer struct {
OS string `json:"os,omitempty"`
Arch string `json:"arch,omitempty"`
Version string `json:"version,omitempty"`
// UTCOffsetSec is the server's UTC offset; nil from servers before 0.128.3.
UTCOffsetSec *int `json:"utc_offset_sec,omitempty"`
}
RunnerServer is the server's own platform and version from GET /v1/runners.
type RunnerWorkerBrief ¶
type RunnerWorkerBrief struct {
GoferVersion string `json:"gofer_version,omitempty"`
}
RunnerWorkerBrief is the part of a worker row's detail the CLI reads.
type RunnerWorkerDetail ¶
type RunnerWorkerDetail struct {
LastHeartbeat int64 `json:"last_heartbeat"`
InFlight int `json:"in_flight"`
Labels []string `json:"labels,omitempty"`
Projects []string `json:"projects,omitempty"`
Agents []string `json:"agents,omitempty"`
ProtocolVersion int `json:"protocol_version,omitempty"`
GoferVersion string `json:"gofer_version,omitempty"`
OS string `json:"os,omitempty"`
Arch string `json:"arch,omitempty"`
Draining bool `json:"draining,omitempty"`
MessengerStatus string `json:"messenger_status,omitempty"`
// MessengerDetail / Dirs come from the worker heartbeat (protocol v16); nil = the
// worker never reported them.
MessengerDetail *struct {
Status string `json:"status"`
} `json:"messenger_detail,omitempty"`
Dirs *struct {
Workspace *struct {
Path string `json:"path"`
Exists bool `json:"exists"`
} `json:"workspace,omitempty"`
} `json:"dirs,omitempty"`
PolicyPending bool `json:"policy_pending,omitempty"`
PolicyRev int64 `json:"policy_rev,omitempty"`
AppliedRev int64 `json:"applied_rev,omitempty"`
PolicyRejected []struct {
Key string `json:"key"`
Reason string `json:"reason"`
} `json:"policy_rejected,omitempty"`
PolicyDegraded []struct {
Key string `json:"key"`
Gate string `json:"gate"`
} `json:"policy_degraded,omitempty"`
}
type RunnersOverview ¶
type RunnersOverview struct {
Runners []RunnerMeta `json:"runners"`
Server RunnerServer `json:"server"`
}
RunnersOverview is the whole GET /v1/runners response.
type SSEEvent ¶
type SSEEvent struct {
// Event is the SSE `event:` field (e.g. "status", "log", "end").
Event string
// Data is the (newline-joined) `data:` payload, typically a JSON object.
Data []byte
}
SSEEvent is one parsed Server-Sent Events frame: the event name and its (joined) data lines. It is the canonical Go-side SSE frame shape shared by the CLI (StreamJob) and the peer-http runner's stream mirroring (P2-a). The server emits these via streaming.writeSSE; events are status / log / log-rotated / interaction / end (see internal/streaming/streaming.go).
func ParseSSE ¶
ParseSSE consumes complete frames from buffer (split on the blank-line frame separator "\n\n") and returns the parsed frames plus the trailing incomplete remainder, which the caller carries into the next read. It mirrors the frontend parser (web/src/api/sse.ts): \r\n is normalised, `event:` / `data:` lines are recognised and a single leading space after `data:` is stripped; multiple data lines are joined with "\n". Frames without an `event:` line are skipped (e.g. the opening ": open" comment).
type Schedule ¶
type Schedule struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Cron string `json:"cron"`
Enabled int `json:"enabled"`
CatchUp int `json:"catch_up"`
NextRunAt int64 `json:"next_run_at"`
LastRunAt int64 `json:"last_run_at"`
LastJobID string `json:"last_job_id"`
ProjectKey string `json:"project_key"`
Request job.JobRequest `json:"request"`
// TriggerToken is the schedule's webhook secret (AUTO-02b); empty = the external
// trigger endpoint is not enabled for it.
TriggerToken string `json:"trigger_token,omitempty"`
}
Schedule is the client-side view of /v1/schedules. It mirrors the HTTP wire shape without importing internal/httpapi from the client package.
type ScopedMemory ¶
type ScopedMemory struct {
Scope string `json:"scope"`
ScopeKey string `json:"scope_key,omitempty"`
Key string `json:"key"`
Content string `json:"content"`
Tags []string `json:"tags,omitempty"`
UpdatedAt string `json:"updated_at"`
UpdatedBy string `json:"updated_by,omitempty"`
Deleted bool `json:"deleted,omitempty"`
tracker.MemoryMeta
}
func (ScopedMemory) TrackerMemory ¶
func (m ScopedMemory) TrackerMemory() tracker.Memory
TrackerMemory is the scoped memory in the local memory shape (prime / ls).
type ScopedMemoryListOpts ¶
type SessionCandidate ¶
SessionCandidate is one agent-session id found in the environment.
func CurrentAgentSessionCandidates ¶
func CurrentAgentSessionCandidates(getenv func(string) string) []SessionCandidate
CurrentAgentSessionCandidates returns the distinct non-empty session ids of AgentSessionEnvKeys in priority order.
type SessionDeliverResult ¶
type SessionDeliverResult struct {
Path string `json:"path"`
JobID string `json:"job_id,omitempty"`
DecisionID string `json:"decision_id,omitempty"`
}
SessionDeliverResult is POST /v1/sessions/{sid}/deliver's answer: where the reply went. Path "turn" means it answered the session's OPEN turn (decision_id is that turn); "tmux" means it was typed into the session's terminal by an internal job; "takeover" means a NEW interactive pty job continues the session (`--resume`) and received the text as its first input (job_id is that job, decision_id its audit row). See sessionrelay.PathTurn / PathTmux / PathTakeover.
type SessionDetail ¶
type SessionDetail struct {
Session AgentSession `json:"session"`
Turns []Decision `json:"turns"`
HasMore bool `json:"has_more"`
NextBefore string `json:"next_before,omitempty"`
}
SessionDetail is GET /v1/sessions/{sid}: the session + recent turns (newest first).
type SessionHeartbeat ¶
type SessionHeartbeat struct {
Event string `json:"event"`
State string `json:"state,omitempty"`
LastMessage string `json:"last_message,omitempty"`
Title string `json:"title,omitempty"`
// Injected: this UserPromptSubmit is the relay's own continuation (no auto-off).
Injected bool `json:"injected,omitempty"`
// IdleSec is the OS input idle time in seconds (-1 = unknown). Set it only on
// events that actually probed: nil means "this beat carries no reading" and
// leaves the server's stored value alone.
IdleSec *int64 `json:"idle_sec,omitempty"`
PeerName string `json:"peer_name,omitempty"`
PeerNameSource string `json:"peer_name_source,omitempty"`
PeerStatus string `json:"peer_status,omitempty"`
PeerMessaging *bool `json:"peer_messaging,omitempty"`
ProgressText string `json:"progress_text,omitempty"`
ProgressAt int64 `json:"progress_at,omitempty"`
ClearProgress bool `json:"clear_progress,omitempty"`
// Cwd is the hook's current directory (the server records it as last_cwd, for display).
Cwd string `json:"cwd,omitempty"`
// SubagentID / SubagentDelta report a SubagentStart (+1) / SubagentStop (-1).
SubagentID string `json:"subagent_id,omitempty"`
SubagentDelta int `json:"subagent_delta,omitempty"`
// UsageDelta is the token usage the hook read from the transcript since its last
// report (N2 §A); the server adds it to the session's total. Nil = none.
UsageDelta *runner.SessionUsage `json:"usage_delta,omitempty"`
}
SessionHeartbeat is the POST /v1/sessions/{sid}/heartbeat body.
type SessionJobWatch ¶
type SessionJobWatch struct {
JobID string `json:"job_id"`
Title string `json:"title,omitempty"`
Status string `json:"status"`
ExitCode int `json:"exit_code"`
StartedAt int64 `json:"started_at,omitempty"`
EndedAt int64 `json:"ended_at,omitempty"`
Duration int64 `json:"duration_sec,omitempty"`
}
SessionJobWatch is a job summary held for Stop-hook completion injection.
type SessionListOpts ¶
SessionListOpts filters ListSessions.
type SessionMessage ¶
type SessionMessage struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Text string `json:"text"`
Operator string `json:"operator,omitempty"`
Status string `json:"status"`
Channel string `json:"channel,omitempty"`
JobID string `json:"job_id,omitempty"`
Error string `json:"error,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
type SessionNudge ¶
type SessionNudge struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Kind string `json:"kind"` // every | stalled
IntervalSec int64 `json:"interval_sec"`
Text string `json:"text"`
UntilAt int64 `json:"until_at,omitempty"`
State string `json:"state"` // active | paused | ended
PauseReason string `json:"pause_reason,omitempty"`
EndedReason string `json:"ended_reason,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt int64 `json:"created_at"`
NextRunAt int64 `json:"next_run_at,omitempty"`
LastFiredAt int64 `json:"last_fired_at,omitempty"`
FireCount int64 `json:"fire_count"`
FailCount int64 `json:"fail_count"`
LastError string `json:"last_error,omitempty"`
}
SessionNudge mirrors httpapi's sessionNudgeView (N2 §E): a timed reminder on a terminal session. Times are unix seconds.
type SessionPermission ¶
type SessionPermission struct {
ToolName string `json:"tool_name"`
Summary string `json:"summary"`
Input string `json:"input,omitempty"`
Suggestions []PermissionSuggestionLabel `json:"suggestions,omitempty"`
Fingerprint string `json:"fp,omitempty"`
TimeoutSec int64 `json:"timeout_sec,omitempty"`
}
SessionPermission is a terminal permission prompt the hook opens on the web (POST /v1/sessions/{sid}/permissions).
type SessionRegister ¶
type SessionRegister struct {
SessionID string `json:"session_id"`
Agent string `json:"agent"`
ProjectKey string `json:"project_key,omitempty"`
Runner string `json:"runner,omitempty"`
Cwd string `json:"cwd,omitempty"`
Title string `json:"title,omitempty"`
Transcript string `json:"transcript,omitempty"`
TmuxPane string `json:"tmux_pane,omitempty"`
Event string `json:"event,omitempty"`
PeerName string `json:"peer_name,omitempty"`
PeerNameSource string `json:"peer_name_source,omitempty"`
PeerStatus string `json:"peer_status,omitempty"`
PeerMessaging bool `json:"peer_messaging,omitempty"`
}
SessionRegister is the POST /v1/sessions body.
type SessionResumePlan ¶
type SessionResumePlan struct {
Can bool `json:"can"`
Reason string `json:"reason,omitempty"`
Message string `json:"message"`
Warning string `json:"warning,omitempty"`
State string `json:"state"`
Ended bool `json:"ended"`
Runner string `json:"runner,omitempty"`
Agent string `json:"agent,omitempty"`
ProjectKey string `json:"project_key,omitempty"`
Cwd string `json:"cwd,omitempty"`
Command []string `json:"command,omitempty"`
// CwdAbs / CwdSource / CwdReason: the directory a wake-up starts in (absolute on
// the runner), where that choice came from (transcript | registered |
// project_root) and why, in plain Chinese.
CwdAbs string `json:"cwd_abs,omitempty"`
CwdSource string `json:"cwd_source,omitempty"`
CwdReason string `json:"cwd_reason,omitempty"`
}
SessionResumePlan is GET /v1/sessions/{sid}/takeover-plan's answer: whether a new process could continue the session (Can) and why not, in plain Chinese.
type SkillImportResult ¶
type SkillImportResult struct {
Skill skill.Skill `json:"skill"`
Replaced bool `json:"replaced,omitempty"`
}
SkillImportResult is the answer to POST /v1/skills/import: the imported skill and whether it replaced a library entry of the same name (import is re-runnable, so "replaced" is information, not an error).
type SkillUpdateResult ¶
type SkillUpdateResult struct {
Skill skill.Skill `json:"skill"`
Change skill.Change `json:"change"`
}
SkillUpdateResult is the answer to POST /v1/skills/{name}/update: the re-fetched metadata and the file-level diff the update produced.
type SkillView ¶
type SkillView struct {
skill.Skill
// Content is the skill's SKILL.md verbatim (frontmatter included). Skipped by
// the listing endpoint, which is why it is a separate type from Skill.
Content string `json:"content,omitempty"`
}
SkillView is one skill as GET /v1/skills/{name} returns it: the index metadata plus the SKILL.md text, so `show` needs one request rather than two.
type StatsBackfillRequest ¶
type StatsBackfillRequest struct {
Since int64 `json:"since,omitempty"`
AfterEnded int64 `json:"after_ended,omitempty"`
AfterID string `json:"after_id,omitempty"`
Limit int `json:"limit,omitempty"`
Force bool `json:"force,omitempty"`
}
StatsBackfillRequest is one POST /v1/stats/backfill batch.
type StatsBackfillResult ¶
type StatsBackfillResult struct {
Scanned int `json:"scanned"`
Written int `json:"written"`
Failed int `json:"failed"`
WithSignal int `json:"with_signal"`
WithGit int `json:"with_git"`
AfterEnded int64 `json:"after_ended"`
AfterID string `json:"after_id"`
Done bool `json:"done"`
}
StatsBackfillResult is one batch's outcome; Done=false means call again with the returned cursor (AfterEnded / AfterID).
type StatsUsage ¶
type StatsUsage struct {
Windows map[string]UsageWindow `json:"windows"`
Partial bool `json:"partial"`
}
StatsUsage is the usage block of GET /v1/stats (SUP-01 E): what each agent burned per window, keyed by the window's label ("24h", "7d"). A window missing from Windows was not computed (see Partial) — a caller must not read it as zero usage.
type StatusError ¶
StatusError is the error doJSON returns for a non-2xx response. Its message is the same friendly text as before; Status lets callers branch on 404/409 without parsing strings (session relay hook: unknown session → re-register).
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type StewardNotesResp ¶
type StewardNotesResp struct {
Notes steward.Notes `json:"notes"`
Info steward.NotesInfo `json:"info"`
}
StewardNotesResp is GET|PUT /v1/steward/notes.
type StewardSettings ¶
type StewardSettings struct {
Enabled bool `json:"enabled"`
Agent string `json:"agent"`
Project string `json:"project"`
ReviewTime string `json:"review_time"`
IdleEndMin int `json:"idle_end_min"`
ReviewMaxItems int `json:"review_max_items"`
EventWake bool `json:"event_wake"`
EventThrottleMin int `json:"event_throttle_min"`
ReviewTimeExplicit bool `json:"review_time_explicit"`
}
StewardSettings is the effective steward: block (GET /v1/steward → settings).
type StewardState ¶
type StewardState struct {
Status steward.Status `json:"status"`
Settings StewardSettings `json:"settings"`
// Warnings are server-side advisories (OBS-13: digest on but no work.digest webhook).
Warnings []string `json:"warnings,omitempty"`
}
StewardState is GET /v1/steward.
type SubmitResult ¶
SubmitResult wraps the create-job response. Async is true when the server could not finish a synchronous submit within its wait cap and returned 202 + X-Gofer-Async (the job keeps running); the caller should poll. For a plain async submit (no sync requested) the server returns 200 and Async is false.
type SupervisorAutoBind ¶
type SupervisorAutoBind struct {
Session AgentSession
EnvKey string
Reason string
}
SupervisorAutoBind reports what plan auto-binding did. Session.SessionID is set only when the plan was created bound to it; otherwise Reason says why nothing was bound (empty Reason + no candidate = no agent session in env).
func (SupervisorAutoBind) Bound ¶
func (b SupervisorAutoBind) Bound() bool
Bound reports whether the plan was bound to the current agent session.
type Todo ¶
type Todo struct {
TodoID string `json:"todo_id"`
PlanID string `json:"plan_id"`
JobID string `json:"job_id,omitempty"`
Title string `json:"title"`
Done bool `json:"done"`
Status string `json:"status,omitempty"`
StartedAt int64 `json:"started_at,omitempty"`
DoneAt int64 `json:"done_at,omitempty"`
Note string `json:"note,omitempty"`
Sort int `json:"sort,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
// PLAN-02 P2 dispatch fields (assignee … dispatch_error).
Assignee string `json:"assignee,omitempty"`
Project string `json:"project,omitempty"`
Template string `json:"template,omitempty"`
Vars map[string]string `json:"vars,omitempty"`
Verify []string `json:"verify,omitempty"`
Review bool `json:"review,omitempty"`
Runner string `json:"runner,omitempty"`
Cwd string `json:"cwd,omitempty"`
TimeoutSec int `json:"timeout_sec,omitempty"`
DispatchError string `json:"dispatch_error,omitempty"`
// PLAN-03 chain fields: After lists the items this one waits for, Auto whether the
// chain may start it, Cmd the argv of an exec item.
After []string `json:"after,omitempty"`
Auto bool `json:"auto"`
Cmd []string `json:"cmd,omitempty"`
// Model is the model the item's job asks for (empty = the agent's own default).
Model string `json:"model,omitempty"`
// Budget is the spend ceiling the item's job runs under (N2 §B).
Budget *job.Budget `json:"budget,omitempty"`
// Acceptance is the item's acceptance criteria (gofer-3nxa.4).
Acceptance string `json:"acceptance,omitempty"`
// Scope is the item's declared change scope (path globs, gofer-3nxa.3).
Scope []string `json:"scope,omitempty"`
// Jobs are the runs attached to this todo (SUP-01 C), newest first — `plan show`
// lists them under the item. Empty for an item nobody has run.
Jobs []TodoJob `json:"jobs,omitempty"`
}
Todo is the client-side view of a plan todo item. JobID "" is a plain todo.
type TodoDispatch ¶
type TodoDispatch struct {
Todo Todo `json:"todo"`
Job *job.JobResult `json:"job,omitempty"`
Dispatched bool `json:"dispatched"`
Reason string `json:"reason,omitempty"`
}
TodoDispatch is the outcome of an explicit dispatch (PLAN-02 P2): POST /v1/todos/{id}/dispatch. Job is nil when nothing was dispatched and Reason says why (the item has no assignee is refused as an error instead; a live job is reported).
type TodoJob ¶
type TodoJob struct {
ID string `json:"id"`
Status string `json:"status"`
Agent string `json:"agent,omitempty"`
StartedAt int64 `json:"started_at,omitempty"`
EndedAt int64 `json:"ended_at,omitempty"`
DurationSec int64 `json:"duration_sec,omitempty"`
}
TodoJob is one job attached to a todo: id/status/agent plus how long it took.
type TodoUpdate ¶
TodoUpdate is one PATCH /v1/todos/{id} body (PLAN-02 P2): the lifecycle fields plus the dispatch fields. A zero value keeps the current one — status "" (note-only or patch-only update), a nil note (keep), an empty append_note (nothing appended), and the patch's nil entries (see jobstore.TodoPatch).
type TrackerRenameResult ¶
type TrackerRenameResult struct {
TrackerID string `json:"tracker_id"`
OldTrackerID string `json:"old_tracker_id"`
Renamed bool `json:"renamed"`
}
TrackerRenameResult is the server's answer to a tracker_id rename.
type TrackerRepoSyncResult ¶
type TrackerRepoSyncResult struct {
JobID string `json:"job_id"`
TrackerID string `json:"tracker_id"`
ProjectKey string `json:"project_key"`
Runner string `json:"runner"`
Cwd string `json:"cwd"`
}
TrackerRepoSyncResult is the server's answer to a dispatched `repo sync` (TRK-05).
type TunnelConn ¶
type TunnelError ¶
TunnelError reports an HTTP tunnel refusal.
func (*TunnelError) Error ¶
func (e *TunnelError) Error() string
type TunnelForwarder ¶
type TunnelForwarder struct {
ID string `json:"id"`
CallerID string `json:"caller_id"`
Worker string `json:"worker"`
Specs []TunnelSpecView `json:"specs"`
Host string `json:"host"`
PID int `json:"pid"`
Hosted bool `json:"hosted"`
HostedName string `json:"hosted_name,omitempty"`
// Caps are what the process advertised ("stop": it can be stopped remotely).
Caps []string `json:"caps,omitempty"`
// StopRequested is true while a remote stop waits for the next heartbeat.
StopRequested bool `json:"stop_requested,omitempty"`
StopRequestedAt *time.Time `json:"stop_requested_at,omitempty"`
StartedAt time.Time `json:"started_at"`
LastSeenAt time.Time `json:"last_seen_at"`
Connections int `json:"connections"`
BytesUp int64 `json:"bytes_up"`
BytesDown int64 `json:"bytes_down"`
}
TunnelForwarder is one online `gofer tun forward` process, with the traffic the hub attributed to it (connections grouped by caller+worker+target).
func (TunnelForwarder) HasCap ¶
func (f TunnelForwarder) HasCap(capability string) bool
HasCap reports whether the forwarder advertised the capability.
type TunnelForwarderRegistration ¶
type TunnelForwarderRegistration struct {
Worker string `json:"worker"`
Specs []TunnelSpecView `json:"specs"`
Host string `json:"host"`
PID int `json:"pid"`
StartedAt time.Time `json:"started_at"`
// Caps advertises what this process understands; ForwarderCapStop means it exits
// when a heartbeat answers 410 (a remote stop).
Caps []string `json:"caps,omitempty"`
}
TunnelForwarderRegistration is what a starting forwarder announces: the rules it is listening on and where it runs. The id and the caller are the hub's to assign.
type TunnelInfo ¶
type TunnelPreset ¶
type TunnelPreset struct {
Name string `json:"name"`
Worker string `json:"worker"`
Specs []string `json:"specs"`
Note string `json:"note"`
Autostart bool `json:"autostart"`
UpdatedAt time.Time `json:"updated_at"`
UpdatedBy string `json:"updated_by"`
}
TunnelPreset is one saved forward preset on the server.
type TunnelSpecView ¶
type TunnelSpecView struct {
Network string `json:"network"`
Bind string `json:"bind"`
LocalPort int `json:"local_port"`
Target string `json:"target"`
}
TunnelSpecView is one forwarding rule as the hub reports it. The hub stores rules structured; the CLI renders them.
func (TunnelSpecView) Display ¶
func (v TunnelSpecView) Display() string
Display renders a rule the way `tun ls` shows it: `[udp/]lport -> target`, with a bind prefix only when it is not the default 127.0.0.1 (the common case needs no noise). ASCII `->` on purpose: the CLI is read in Windows consoles too.
type TurnStatus ¶
type TurnStatus struct {
Outcome string `json:"outcome"`
Relay bool `json:"relay"`
WaitReason string `json:"wait_reason,omitempty"`
// WaitReasonDetail says why a wait that ISN'T arming (SUP-01 D): the caller is
// supervising live jobs. Logged by the hook, never acted on.
WaitReasonDetail string `json:"wait_reason_detail,omitempty"`
Decision Decision `json:"decision"`
}
TurnStatus is GET /v1/sessions/{sid}/turns/{id}: outcome is one of open|answered|expired|relay_off; Decision.Answer holds the reply when answered. WaitReason is why the session still waits (mode_on / idle_probe / turn_age; empty = it stopped waiting), see AgentSession.WaitReason.
type UsageAgent ¶
type UsageAgent struct {
Jobs int `json:"jobs"`
TotalTokens int64 `json:"total_tokens"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CostUSD float64 `json:"cost_usd"`
}
UsageAgent is one agent's tally in a window: Jobs counts every job it ran, the sums only the jobs that reported usage.
type UsageWindow ¶
type UsageWindow struct {
ByAgent map[string]UsageAgent `json:"by_agent"`
Total UsageAgent `json:"total"`
}
UsageWindow is one window of the aggregate: per-agent tallies plus their sum.
type Wakeup ¶
type Wakeup struct {
ID string `json:"id"`
JobID string `json:"job_id"`
Kind string `json:"kind"`
At int64 `json:"at,omitempty"`
EverySec int64 `json:"every_sec,omitempty"`
Cron string `json:"cron,omitempty"`
Timezone string `json:"timezone,omitempty"`
EventTypes []string `json:"event_types,omitempty"`
FilterJobID string `json:"filter_job_id,omitempty"`
FilterStatus []string `json:"filter_status,omitempty"`
Mode string `json:"mode"`
Instruction string `json:"instruction,omitempty"`
Enabled bool `json:"enabled"`
Revision int64 `json:"revision"`
NextRunAt int64 `json:"next_run_at,omitempty"`
LastFiredAt int64 `json:"last_fired_at,omitempty"`
FiredCount int64 `json:"fired_count"`
CoalescedCount int64 `json:"coalesced_count"`
ContinuationJobID string `json:"continuation_job_id,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt int64 `json:"created_at"`
ExpiresAt int64 `json:"expires_at,omitempty"`
}
Wakeup is the client-side view of one JOB-09 wakeup (design §五.1): an event subscription or timer registered on a job that starts a continuation of it when it fires. Timestamps are unix SECONDS; Enabled is the switch the web toggles.
type WakeupsResp ¶
type WakeupsResp struct {
Wakeups []Wakeup `json:"wakeups"`
}
WakeupsResp is the `{wakeups: [...]}` envelope of the list endpoint.
type WatchHandlers ¶
WatchHandlers carries the presentation callbacks for WatchJob. The watch state-machine (SSE consumption + status/EOF tracking) lives here in client; the command layer supplies these callbacks to print and to derive a process exit code (the exit-code mapping is a command concern, kept in commands).
- OnStatus fires once per status CHANGE (the first time a new status is seen).
- OnLog fires for each non-empty log frame's raw text.
Both may be nil.
type WorkListOpts ¶
type WorkListOpts struct {
Statuses []string
Project string
Workspace string
Session string
Query string
Unsorted *bool
Closed bool
// Merged includes items that were merged into another (hidden by default).
Merged bool
Due bool
Limit int
}
WorkListOpts filters ListWorkItems (mirrors GET /v1/work-items).
type WorkReportRequestResult ¶
type WorkReportRequestResult struct {
SessionID string `json:"session_id"`
RequestID string `json:"request_id,omitempty"`
Kind string `json:"kind,omitempty"`
State string `json:"state,omitempty"`
Sent bool `json:"sent"`
Channel string `json:"channel,omitempty"`
Reason string `json:"reason,omitempty"`
}
WorkReportRequestResult is the per-session outcome of "ask it to report".
type WorkSplitResult ¶
type WorkSplitResult struct {
Source work.DetailView `json:"source"`
Item work.DetailView `json:"item"`
}
WorkSplitResult is the split response: the source and the new item.
type WorkToTodoResult ¶
type WorkToTodoResult struct {
TodoID string `json:"todo_id"`
PlanID string `json:"plan_id"`
PlanCreated bool `json:"plan_created"`
Item work.DetailView `json:"item"`
}
WorkToTodoResult is what POST /v1/work-items/{id}/to-todo returns.
type WorkerAssignable ¶
type WorkerAssignable struct {
WorkerID string `json:"worker_id"`
Projects []AssignableProject `json:"projects"`
ServerVersion string `json:"server_version,omitempty"`
ProtocolVersion int `json:"protocol_version"`
}
WorkerAssignable is the wizard's server-side briefing (CFG-05): the projects whose allowed_runners may route to this worker, plus the server and wire protocol versions it is onboarding against.
type WorkerCaps ¶
type WorkerCaps struct {
Labels []string `json:"labels"`
Projects []string `json:"projects"`
Agents []string `json:"agents"`
MaxConcurrent int `json:"max_concurrent"`
}
WorkerCaps is a worker's capability snapshot as reported by a successful reload.
type WorkerDetail ¶
type WorkerDetail struct {
WorkerID string `json:"worker_id"`
Connected bool `json:"connected"`
Worker *RunnerWorkerDetail `json:"worker,omitempty"`
// Upgrade is the latest remote-upgrade attempt (any state), nil when none.
Upgrade *WorkerUpgradeRecord `json:"upgrade,omitempty"`
UpgradeHistory []WorkerUpgradeRecord `json:"upgrade_history,omitempty"`
}
type WorkerMeta ¶
type WorkerMeta struct {
ID string `json:"id"`
Labels []string `json:"labels,omitempty"`
Projects []string `json:"projects,omitempty"`
Agents []string `json:"agents,omitempty"`
AgentCaps []RunnerAgentMeta `json:"agent_caps,omitempty"`
Connected bool `json:"connected"`
}
WorkerMeta is one worker returned by GET /v1/meta. It is deliberately a client-side wire type so commands can inspect the server without importing the HTTP API package.
type WorkerRegistration ¶
type WorkerReload ¶
type WorkerReload struct {
WorkerID string `json:"worker_id"`
Applied bool `json:"applied"`
Caps *WorkerCaps `json:"caps,omitempty"`
}
WorkerReload is the reload endpoint's answer. Applied=true means the worker is now running the new config and Caps is its resulting capability snapshot.
type WorkerUpgradeOptions ¶
type WorkerUpgradeOptions struct {
Source string `json:"source,omitempty"`
Force bool `json:"force,omitempty"`
DrainTimeoutSec int `json:"drain_timeout_sec,omitempty"`
ReadyTimeoutSec int `json:"ready_timeout_sec,omitempty"`
}
WorkerUpgradeOptions is the body of POST /v1/workers/{id}/upgrade. Source is "staged" (the binary uploaded with StageWorkerUpgrade) or "server" (the server's own executable; the default).
type WorkerUpgradeRecord ¶
type WorkerUpgradeRecord struct {
WorkerID string `json:"worker_id"`
UpgradeID string `json:"upgrade_id"`
State string `json:"state"`
FromVersion string `json:"from_version,omitempty"`
TargetVersion string `json:"target_version,omitempty"`
TargetSHA256 string `json:"target_sha256,omitempty"`
Force bool `json:"force,omitempty"`
Error string `json:"error,omitempty"`
StartedAt int64 `json:"started_at"`
FinishedAt int64 `json:"finished_at,omitempty"`
DurationMS int64 `json:"duration_ms,omitempty"`
}
WorkerUpgradeRecord is the latest remote-upgrade attempt of one worker. Times are unix milliseconds.
type Workflow ¶
type Workflow struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
Status string `json:"status"`
CurrentStep int `json:"current_step"`
TotalSteps int `json:"total_steps"`
CallerID string `json:"caller_id,omitempty"`
Error string `json:"error,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
Steps []WorkflowStep `json:"steps,omitempty"`
}
Workflow is the client-side view of a job-chain. It carries the workflow header fields plus (for GetWorkflow) the per-step chain. List/Submit/Cancel return the header only, so Steps is nil there; GetWorkflow inlines the chain. Field tags match httpapi's workflowSummary / workflowDetail JSON so one struct decodes both.
type WorkflowEvent ¶
type WorkflowEvent struct {
Seq int64 `json:"seq"`
WorkflowID string `json:"workflow_id"`
Type string `json:"type"`
Detail string `json:"detail,omitempty"`
At int64 `json:"at"`
}
WorkflowEvent mirrors jobstore.WorkflowEvent's JSON (P1 timeline): the monotonic seq cursor, the event type, an optional detail_json blob and the unix-second timestamp. Used by `workflow events` (T4.3).
type WorkflowStep ¶
type WorkflowStep struct {
StepIndex int `json:"step_index"`
Attempt int `json:"attempt,omitempty"`
FanIndex int `json:"fan_index,omitempty"`
Name string `json:"name,omitempty"`
JobID string `json:"job_id,omitempty"`
Status string `json:"status,omitempty"`
// Type=="workflow" + ChildWorkflowID mark a sub-workflow step (P3 UI fix): it runs
// no step-job, so JobID is empty and the link target is the child workflow.
Type string `json:"type,omitempty"`
ChildWorkflowID string `json:"child_workflow_id,omitempty"`
WorktreeBranch string `json:"worktree_branch,omitempty"`
Diff string `json:"diff,omitempty"`
DiffSummary string `json:"diff_summary,omitempty"`
}
WorkflowStep is one row of a workflow's step chain in the detail response, mirroring httpapi's workflow.Step JSON (snake_case). job_id/status are empty for a step not yet started (the chain is strictly serial). Attempt is the 1-based retry attempt of this step-job (P1) and FanIndex the 1-based fan-out parallel index (P2); both are 0/omitted for a v1 single-job step, so the CLI only renders them when a step actually fanned out / retried (T4.3 `workflow show`).
type XferRecord ¶
type XferRecord struct {
ID string `json:"id"`
Op string `json:"op"`
Runner string `json:"runner"`
Project string `json:"project"`
Path string `json:"path"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
State string `json:"state"`
Error string `json:"error,omitempty"`
CallerID string `json:"caller_id,omitempty"`
CreatedAt int64 `json:"created_at"`
FinishedAt int64 `json:"finished_at,omitempty"`
ExpiresAt int64 `json:"expires_at,omitempty"`
}
XferRecord is one transfer journal row (GET /v1/xfer/{id}). Its JSON tags are the wire keys the server's xferView uses: `project` names the project (not project_key) and every timestamp is unix SECONDS.
Source Files
¶
- client.go
- job_delete.go
- job_redact.go
- job_secret_scan.go
- memory_candidates.go
- plan_autobind.go
- rules.go
- runners.go
- scoped_memories.go
- session_permission.go
- skills.go
- sse.go
- stats.go
- steward.go
- today.go
- tracker_sync.go
- tunnel_presets.go
- watch.go
- work.go
- worker_assignable.go
- worker_registration.go
- worker_upgrade.go
- workers.go
- xfer.go