package runnerproto import ( "encoding/json" "time" "amadan.net/oficina/equipo/internal/equipo/team" "amadan.net/oficina/equipo/internal/runner/provider" ) const ( Version = 1 // Device enrolment and credential storage. DirectVersion = provider.Version DeviceAudience = "equipo.device.v1" RunnerAudience = "equipo.runner.v1" PollIntervalSeconds = 5 ) type BeginEnrolmentRequest struct { Version int `json:"version"` MachinePublicKey string `json:"machine_public_key"` Label string `json:"label"` // WorkerOnly: the machine can only be a worker (a Mac). The instance // refuses to approve it for a person with no primary runner. WorkerOnly bool `json:"worker_only,omitempty"` } type DeviceCode struct { Version int `json:"version"` EnrolmentID string `json:"enrolment_id"` InstanceID string `json:"instance_id"` DeviceSecret string `json:"device_secret"` UserCode string `json:"user_code"` Challenge string `json:"challenge"` VerificationURI string `json:"verification_uri"` ExpiresAt time.Time `json:"expires_at"` PollIntervalSeconds int `json:"poll_interval_seconds"` } type ExchangeProof struct { EnrolmentID string `json:"enrolment_id"` Challenge string `json:"challenge"` ExchangeNonce string `json:"exchange_nonce"` Signature string `json:"signature"` } type ExchangeEnrolmentRequest struct { Version int `json:"version"` DeviceSecret string `json:"device_secret"` Proof ExchangeProof `json:"proof"` } type RunnerCredential struct { Version int `json:"version"` Token string `json:"token"` TokenType string `json:"token_type"` RunnerID string `json:"runner_id"` CredentialID string `json:"credential_id"` Person string `json:"person"` ExpiresAt time.Time `json:"expires_at"` // Role is "worker" for a worker (protocol 2 instances say so at // enrolment); absent means primary, as an older instance's credential // is. The runner keeps it with the credential. Role string `json:"role,omitempty"` } type ErrorResponse struct { Version int `json:"version"` Error string `json:"error"` } const ( CleanupAudience = "cleanup" LongPollSeconds = 2 RenewSeconds = 15 MaxActionBytes = 64 << 10 MaxEventBytes = 16 << 10 MaxArtifactBytes = 1 << 20 ) type ClaimRequest struct { Version int `json:"version"` AssignmentID string `json:"assignment_id"` Revision int64 `json:"revision"` RequestID string `json:"request_id"` } type PollRequest struct { Version int `json:"version"` After string `json:"after"` } type RunnerRequest struct { ArtifactID team.ArtifactID `json:"artifact_id,omitempty"` Question *Question `json:"question,omitempty"` Version int `json:"version"` AssignmentID string `json:"assignment_id"` Scope team.Scope `json:"scope"` Handle team.Handle `json:"handle"` RequestID string `json:"request_id"` ActionID team.ActionID `json:"action_id,omitempty"` Intent *team.IntentSpec `json:"intent,omitempty"` Receipt *team.Receipt `json:"receipt,omitempty"` Artifact *team.ArtifactSpec `json:"artifact,omitempty"` Event json.RawMessage `json:"event,omitempty"` Prepared json.RawMessage `json:"prepared,omitempty"` Proof json.RawMessage `json:"proof,omitempty"` Result *team.AttemptResult `json:"result,omitempty"` Reason team.WaitReason `json:"reason,omitempty"` } type WorkResponse struct { Version int `json:"version"` Result any `json:"result"` } type HeartbeatRequest struct { Repositories []string `json:"repositories,omitempty"` RequestID string `json:"request_id"` Version int `json:"version"` Reports json.RawMessage `json:"reports,omitempty"` RotationRequestID string `json:"rotation_request_id,omitempty"` } type Delivery struct { Ticket team.AdmissionTicket `json:"ticket"` ReceivedAt time.Time `json:"received_at"` } type ConnectionRouting struct { BindingID, AccountID, ObservedAccountID, CredentialHomeHash string AccountPinned, NoFailover, TimelineRecovery, ProcessOwnership, DedicatedUser bool } type ConnectionReport struct { SignInCommand string `json:",omitempty"` OwnerMode bool `json:",omitempty"` LauncherVersion, BwrapVersion, PolicyVersion string TrialReady bool ProviderVersionSource string LocalID, Provider, ProviderVersion, PaseoVersion, Family, Model, AccountLabel, Kind, UnavailableReason, IsolationConfigHash string Available, ReadIsolation, AllowanceKnown bool AllowanceRemaining int64 Routing ConnectionRouting } type Selection struct { ConnectionID, RunnerID, Person, Provider, Family, Model, AccountLabel, AccountID string Revision, ChoiceRevision, SpecialistRevision int64 Reason string MaxConcurrent int AllowanceKnown bool AllowanceRemaining int64 Isolation team.IsolationSnapshot } type Assignment struct { ID string `json:"id"` TaskID string `json:"task_id"` StepKey string `json:"step_key"` WorkspaceKey string `json:"workspace_key"` Scope Scope `json:"scope"` Selection Selection `json:"selection"` Revision int64 `json:"revision"` Kind string `json:"kind"` } type StepBrief struct { SpecialistName, SpecialistIcon string PlanRevision int64 StepKey, SpecialistKey, Action string SpecialistRevision int64 ArtifactHashes []string } type SourceSnapshot struct { Ref team.SourceRef `json:"ref"` Payload json.RawMessage `json:"payload"` } type RunnerBrief struct { ProjectRevision, BudgetRevision int64 Step StepBrief `json:"step"` Sources []SourceSnapshot `json:"sources,omitempty"` RenderRecipe *RenderRecipe `json:"render_recipe,omitempty"` AttemptDeadline time.Time `json:"attempt_deadline"` CheckDefinition []byte `json:"check_definition"` Target team.TargetBinding `json:"target"` Instructions string `json:"instructions"` StandingInstructions string `json:"standing_instructions"` ConfirmedPreferences []string `json:"confirmed_preferences"` Selection Selection `json:"selection"` Policy team.Policy `json:"policy"` ArtifactHashes []string `json:"artifact_hashes"` } type ClaimResponse struct { CleanupExpired bool `json:"cleanup_expired,omitempty"` NotClaimed bool `json:"not_claimed,omitempty"` AttemptDeadline time.Time `json:"attempt_deadline"` Scope Scope `json:"scope"` Handle team.Handle `json:"handle"` Brief RunnerBrief `json:"brief"` LeaseDeadline time.Time `json:"lease_deadline"` CleanupToken string `json:"cleanup_token"` CleanupExpiresAt time.Time `json:"cleanup_expires_at"` RenewSeconds int `json:"renew_seconds"` } type CredentialRotation struct { Bearer RunnerCredential `json:"bearer"` CleanupTokens map[string]string `json:"cleanup_tokens"` } type Scope = team.Scope type PreparedBug struct { Repository, DefaultBranch, BaseCommit string CheckDefinition []byte CheckDefinitionHash, BaselineTestSetHash string } type CheckCommand struct { Argv []string `json:"argv"` Dir string `json:"dir"` Parser string `json:"parser"` TimeoutSeconds int `json:"timeout_seconds"` } type CheckFile struct { Path string `json:"path"` Bytes []byte `json:"bytes"` } type TestBaseline struct { Names []team.TestIdentity `json:"names"` Hash string `json:"hash"` } type CheckDefinition struct { Render *RenderRecipe `json:"render,omitempty"` TrustedPaths []string `json:"trusted_paths"` Version int `json:"version"` Repository string `json:"repository"` Base string `json:"base"` Commands []CheckCommand `json:"commands"` Reproduction CheckCommand `json:"reproduction"` Baseline TestBaseline `json:"baseline"` Files []CheckFile `json:"files"` TestFiles []string `json:"test_files"` GOOS string `json:"goos"` GOARCH string `json:"goarch"` } type Reproduction struct { ExpectedSymptom string `json:"expected_symptom"` Files []CheckFile `json:"files"` TestNames []team.TestIdentity `json:"test_names"` } type BlobRequest struct { Version int `json:"version"` Scope team.Scope `json:"scope"` Handle team.Handle `json:"handle"` Digest string `json:"digest"` Bytes []byte `json:"bytes"` } type BlobReadRequest struct { Version int `json:"version"` Scope team.Scope `json:"scope"` Digest string `json:"digest"` } type DispatchTicket = team.AdmissionTicket type PublicationAuthorization = team.PublicationAuthorization type RenderRecipe struct { Version int `json:"version"` Command CheckCommand `json:"command"` }