syntax = "proto3";

package temporal.api.workflowservice.v1;

option go_package = "go.temporal.io/api/workflowservice/v1;workflowservice";
option java_package = "io.temporal.api.workflowservice.v1";
option java_multiple_files = true;
option java_outer_classname = "RequestResponseProto";
option ruby_package = "Temporalio::Api::WorkflowService::V1";
option csharp_namespace = "Temporalio.Api.WorkflowService.V1";

import "temporal/api/enums/v1/batch_operation.proto";
import "temporal/api/enums/v1/common.proto";
import "temporal/api/enums/v1/workflow.proto";
import "temporal/api/enums/v1/namespace.proto";
import "temporal/api/enums/v1/failed_cause.proto";
import "temporal/api/enums/v1/query.proto";
import "temporal/api/enums/v1/reset.proto";
import "temporal/api/enums/v1/task_queue.proto";
import "temporal/api/enums/v1/deployment.proto";
import "temporal/api/enums/v1/update.proto";
import "temporal/api/enums/v1/activity.proto";
import "temporal/api/enums/v1/nexus.proto";
import "temporal/api/activity/v1/message.proto";
import "temporal/api/common/v1/message.proto";
import "temporal/api/history/v1/message.proto";
import "temporal/api/workflow/v1/message.proto";
import "temporal/api/command/v1/message.proto";
import "temporal/api/compute/v1/config.proto";
import "temporal/api/deployment/v1/message.proto";
import "temporal/api/failure/v1/message.proto";
import "temporal/api/filter/v1/message.proto";
import "temporal/api/protocol/v1/message.proto";
import "temporal/api/namespace/v1/message.proto";
import "temporal/api/query/v1/message.proto";
import "temporal/api/replication/v1/message.proto";
import "temporal/api/rules/v1/message.proto";
import "temporal/api/sdk/v1/worker_config.proto";
import "temporal/api/schedule/v1/message.proto";
import "temporal/api/taskqueue/v1/message.proto";
import "temporal/api/update/v1/message.proto";
import "temporal/api/version/v1/message.proto";
import "temporal/api/batch/v1/message.proto";
import "temporal/api/sdk/v1/task_complete_metadata.proto";
import "temporal/api/sdk/v1/user_metadata.proto";
import "temporal/api/nexus/v1/message.proto";
import "temporal/api/worker/v1/message.proto";

import "google/protobuf/duration.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";

message RegisterNamespaceRequest {
    string namespace = 1;
    string description = 2;
    string owner_email = 3;
    google.protobuf.Duration workflow_execution_retention_period = 4;
    repeated temporal.api.replication.v1.ClusterReplicationConfig clusters = 5;
    string active_cluster_name = 6;
    // A key-value map for any customized purpose.
    map<string, string> data = 7;
    string security_token = 8;
    bool is_global_namespace = 9;
    // If unspecified (ARCHIVAL_STATE_UNSPECIFIED) then default server configuration is used.
    temporal.api.enums.v1.ArchivalState history_archival_state = 10;
    string history_archival_uri = 11;
    // If unspecified (ARCHIVAL_STATE_UNSPECIFIED) then default server configuration is used.
    temporal.api.enums.v1.ArchivalState visibility_archival_state = 12;
    string visibility_archival_uri = 13;
}

message RegisterNamespaceResponse {
}

message ListNamespacesRequest {
    int32 page_size = 1;
    bytes next_page_token = 2;
    temporal.api.namespace.v1.NamespaceFilter namespace_filter = 3;
}

message ListNamespacesResponse {
    repeated DescribeNamespaceResponse namespaces = 1;
    bytes next_page_token = 2;
}

message DescribeNamespaceRequest {
    string namespace = 1;
    string id = 2;
}

message DescribeNamespaceResponse {
    temporal.api.namespace.v1.NamespaceInfo namespace_info = 1;
    temporal.api.namespace.v1.NamespaceConfig config = 2;
    temporal.api.replication.v1.NamespaceReplicationConfig replication_config = 3;
    int64 failover_version = 4;
    bool is_global_namespace = 5;
    // Contains the historical state of failover_versions for the cluster, truncated to contain only the last N
    // states to ensure that the list does not grow unbounded.
    repeated temporal.api.replication.v1.FailoverStatus failover_history = 6;
}

message UpdateNamespaceRequest {
    string namespace = 1;
    temporal.api.namespace.v1.UpdateNamespaceInfo update_info = 2;
    temporal.api.namespace.v1.NamespaceConfig config = 3;
    temporal.api.replication.v1.NamespaceReplicationConfig replication_config = 4;
    string security_token = 5;
    string delete_bad_binary = 6;
    // promote local namespace to global namespace. Ignored if namespace is already global namespace.
    bool promote_namespace = 7;
}

message UpdateNamespaceResponse {
    temporal.api.namespace.v1.NamespaceInfo namespace_info = 1;
    temporal.api.namespace.v1.NamespaceConfig config = 2;
    temporal.api.replication.v1.NamespaceReplicationConfig replication_config = 3;
    int64 failover_version = 4;
    bool is_global_namespace = 5;
}

// Deprecated.
message DeprecateNamespaceRequest {
    string namespace = 1;
    string security_token = 2;
}

// Deprecated.
message DeprecateNamespaceResponse {
}

message StartWorkflowExecutionRequest {
    string namespace = 1;
    string workflow_id = 2;
    temporal.api.common.v1.WorkflowType workflow_type = 3;
    temporal.api.taskqueue.v1.TaskQueue task_queue = 4;
    // Serialized arguments to the workflow. These are passed as arguments to the workflow function.
    temporal.api.common.v1.Payloads input = 5;
    // Total workflow execution timeout including retries and continue as new.
    google.protobuf.Duration workflow_execution_timeout = 6;
    // Timeout of a single workflow run.
    google.protobuf.Duration workflow_run_timeout = 7;
    // Timeout of a single workflow task.
    google.protobuf.Duration workflow_task_timeout = 8;
    // The identity of the client who initiated this request
    string identity = 9;
    // A unique identifier for this start request. Typically UUIDv4.
    string request_id = 10;
    // Defines whether to allow re-using the workflow id from a previously *closed* workflow.
    // The default policy is WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE.
    //
    // See `workflow_id_conflict_policy` for handling a workflow id duplication with a *running* workflow.
    temporal.api.enums.v1.WorkflowIdReusePolicy workflow_id_reuse_policy = 11;
    // Defines how to resolve a workflow id conflict with a *running* workflow.
    // The default policy is WORKFLOW_ID_CONFLICT_POLICY_FAIL.
    //
    // See `workflow_id_reuse_policy` for handling a workflow id duplication with a *closed* workflow.
    temporal.api.enums.v1.WorkflowIdConflictPolicy workflow_id_conflict_policy = 22;
    // The retry policy for the workflow. Will never exceed `workflow_execution_timeout`.
    temporal.api.common.v1.RetryPolicy retry_policy = 12;
    // See https://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/
    string cron_schedule = 13;
    temporal.api.common.v1.Memo memo = 14;
    temporal.api.common.v1.SearchAttributes search_attributes = 15;
    temporal.api.common.v1.Header header = 16;
    // Request to get the first workflow task inline in the response bypassing matching service and worker polling.
    // If set to `true` the caller is expected to have a worker available and capable of processing the task.
    // The returned task will be marked as started and is expected to be completed by the specified
    // `workflow_task_timeout`.
    bool request_eager_execution = 17;
    // These values will be available as ContinuedFailure and LastCompletionResult in the
    // WorkflowExecutionStarted event and through SDKs. The are currently only used by the
    // server itself (for the schedules feature) and are not intended to be exposed in
    // StartWorkflowExecution.
    temporal.api.failure.v1.Failure continued_failure = 18;
    temporal.api.common.v1.Payloads last_completion_result = 19;
    // Time to wait before dispatching the first workflow task. Cannot be used with `cron_schedule`.
    // If the workflow gets a signal before the delay, a workflow task will be dispatched and the rest
    // of the delay will be ignored.
    google.protobuf.Duration workflow_start_delay = 20;
    // Callbacks to be called by the server when this workflow reaches a terminal state.
    // If the workflow continues-as-new, these callbacks will be carried over to the new execution.
    // Callback addresses must be whitelisted in the server's dynamic configuration.
    repeated temporal.api.common.v1.Callback completion_callbacks = 21;
    // Metadata on the workflow if it is started. This is carried over to the WorkflowExecutionInfo
    // for use by user interfaces to display the fixed as-of-start summary and details of the
    // workflow.
    temporal.api.sdk.v1.UserMetadata user_metadata = 23;
    // Links to be associated with the workflow.
    repeated temporal.api.common.v1.Link links = 24;
    // If set, takes precedence over the Versioning Behavior sent by the SDK on Workflow Task completion.
    // To unset the override after the workflow is running, use UpdateWorkflowExecutionOptions.
    temporal.api.workflow.v1.VersioningOverride versioning_override = 25;
    // Defines actions to be done to the existing running workflow when the conflict policy
    // WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING is used. If not set (ie., nil value) or set to a
    // empty object (ie., all options with default value), it won't do anything to the existing
    // running workflow. If set, it will add a history event to the running workflow.
    temporal.api.workflow.v1.OnConflictOptions on_conflict_options = 26;
    // Priority metadata
    temporal.api.common.v1.Priority priority = 27;
    // Deployment Options of the worker who will process the eager task. Passed when `request_eager_execution=true`.
    temporal.api.deployment.v1.WorkerDeploymentOptions eager_worker_deployment_options = 28;
    // Time-skipping configuration. If not set, time skipping is disabled.
    temporal.api.workflow.v1.TimeSkippingConfig time_skipping_config = 29;
}

message StartWorkflowExecutionResponse {
    // The run id of the workflow that was started - or used (via WorkflowIdConflictPolicy USE_EXISTING).
    string run_id = 1;
    // If true, a new workflow was started.
    bool started = 3;
    // Current execution status of the workflow. Typically remains WORKFLOW_EXECUTION_STATUS_RUNNING
    // unless a de-dupe occurs or in specific scenarios handled within the ExecuteMultiOperation (refer to its docs).
    temporal.api.enums.v1.WorkflowExecutionStatus status = 5;
    // When `request_eager_execution` is set on the `StartWorkflowExecutionRequest`, the server - if supported - will
    // return the first workflow task to be eagerly executed.
    // The caller is expected to have a worker available to process the task.
    PollWorkflowTaskQueueResponse eager_workflow_task = 2;
    // Link to the workflow event.
    temporal.api.common.v1.Link link = 4;
}

message GetWorkflowExecutionHistoryRequest {
    string namespace = 1;
    temporal.api.common.v1.WorkflowExecution execution = 2;
    int32 maximum_page_size = 3;
    // If a `GetWorkflowExecutionHistoryResponse` or a `PollWorkflowTaskQueueResponse` had one of
    // these, it should be passed here to fetch the next page.
    bytes next_page_token = 4;
    // If set to true, the RPC call will not resolve until there is a new event which matches
    // the `history_event_filter_type`, or a timeout is hit.
    bool wait_new_event = 5;
    // Filter returned events such that they match the specified filter type.
    // Default: HISTORY_EVENT_FILTER_TYPE_ALL_EVENT.
    temporal.api.enums.v1.HistoryEventFilterType history_event_filter_type = 6;
    bool skip_archival = 7;
}

message GetWorkflowExecutionHistoryResponse {
    temporal.api.history.v1.History history = 1;
    // Raw history is an alternate representation of history that may be returned if configured on
    // the frontend. This is not supported by all SDKs. Either this or `history` will be set.
    repeated temporal.api.common.v1.DataBlob raw_history = 2;
    // Will be set if there are more history events than were included in this response
    bytes next_page_token = 3;
    bool archived = 4;
}

message GetWorkflowExecutionHistoryReverseRequest {
    string namespace = 1;
    temporal.api.common.v1.WorkflowExecution execution = 2;
    int32 maximum_page_size = 3;
    bytes next_page_token = 4;
}

message GetWorkflowExecutionHistoryReverseResponse {
    temporal.api.history.v1.History history = 1;
    // Will be set if there are more history events than were included in this response
    bytes next_page_token = 3;
}

message PollWorkflowTaskQueueRequest {
    string namespace = 1;
    temporal.api.taskqueue.v1.TaskQueue task_queue = 2;
    // Unless this is the first poll, the client must pass one of the poller group IDs received in
    // `poller_group_infos` of the last the PollWorkflowTaskQueueResponse according to the
    // instructions. If not set, the poll is routed randomly which can cause it being blocked
    // without receiving a task while the queue actually has tasks in another server location.
    string poller_group_id = 10;
    // The identity of the worker/client who is polling this task queue
    string identity = 3;
    // A unique key for this worker instance, used for tracking worker lifecycle.
    // This is guaranteed to be unique, whereas identity is not guaranteed to be unique.
    string worker_instance_key = 8;

    // A dedicated per-worker Nexus task queue on which the server sends control
    // tasks (e.g. activity cancellation) to this specific worker instance.
    string worker_control_task_queue = 9;

    // Deprecated. Use deployment_options instead.
    // Each worker process should provide an ID unique to the specific set of code it is running
    // "checksum" in this field name isn't very accurate, it should be though of as an id.
    string binary_checksum = 4 [deprecated = true];
    // Deprecated. Use deployment_options instead.
    // Information about this worker's build identifier and if it is choosing to use the versioning
    // feature. See the `WorkerVersionCapabilities` docstring for more.
    temporal.api.common.v1.WorkerVersionCapabilities worker_version_capabilities = 5 [deprecated = true];
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 6;

    // Removed in 1.55.0; was temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat
    reserved 7;
    reserved "worker_heartbeat";
}

message PollWorkflowTaskQueueResponse {
    // A unique identifier for this task
    bytes task_token = 1;
    temporal.api.common.v1.WorkflowExecution workflow_execution = 2;
    temporal.api.common.v1.WorkflowType workflow_type = 3;
    // The last workflow task started event which was processed by some worker for this execution.
    // Will be zero if no task has ever started.
    int64 previous_started_event_id = 4;
    // The id of the most recent workflow task started event, which will have been generated as a
    // result of this poll request being served. Will be zero if the task
    // does not contain any events which would advance history (no new WFT started).
    // Currently this can happen for queries.
    int64 started_event_id = 5;
    // Starting at 1, the number of attempts to complete this task by any worker.
    int32 attempt = 6;
    // A hint that there are more tasks already present in this task queue
    // partition. Can be used to prioritize draining a sticky queue.
    //
    // Specifically, the returned number is the number of tasks remaining in
    // the in-memory buffer for this partition, which is currently capped at
    // 1000. Because sticky queues only have one partition, this number is
    // more useful when draining them. Normal queues, typically having more than one
    // partition, will return a number representing only some portion of the
    // overall backlog. Subsequent RPCs may not hit the same partition as
    // this call.
    int64 backlog_count_hint = 7;
    // The history for this workflow, which will either be complete or partial. Partial histories
    // are sent to workers who have signaled that they are using a sticky queue when completing
    // a workflow task.
    temporal.api.history.v1.History history = 8;
    // Will be set if there are more history events than were included in this response. Such events
    // should be fetched via `GetWorkflowExecutionHistory`.
    bytes next_page_token = 9;
    // Legacy queries appear in this field. The query must be responded to via
    // `RespondQueryTaskCompleted`. If the workflow is already closed (queries are permitted on
    // closed workflows) then the `history` field will be populated with the entire history. It
    // may also be populated if this task originates on a non-sticky queue.
    temporal.api.query.v1.WorkflowQuery query = 10;
    // The task queue this task originated from, which will always be the original non-sticky name
    // for the queue, even if this response came from polling a sticky queue.
    temporal.api.taskqueue.v1.TaskQueue workflow_execution_task_queue = 11;
    // When this task was scheduled by the server
    google.protobuf.Timestamp scheduled_time = 12;
    // When the current workflow task started event was generated, meaning the current attempt.
    google.protobuf.Timestamp started_time = 13;
    // Queries that should be executed after applying the history in this task. Responses should be
    // attached to `RespondWorkflowTaskCompletedRequest::query_results`
    map<string, temporal.api.query.v1.WorkflowQuery> queries = 14;
    // Protocol messages piggybacking on a WFT as a transport
    repeated temporal.api.protocol.v1.Message messages = 15;
    // Server-advised information the SDK may use to adjust its poller count.
    temporal.api.taskqueue.v1.PollerScalingDecision poller_scaling_decision = 16;
    // This poller group ID identifies the owner of the workflow task awaiting for query response.
    // Corresponding RespondQueryTaskCompleted should pass this value for proper routing.
    string poller_group_id = 17;
    // The weighted list of poller groups IDs that client should use for future polls to this task
    // queue. Client is expected to:
    //   1. Maintain minimum number of pollers no less than the number of groups.
    //   2. Try to assign the next poll to a group without any pending polls,
    //   3. If every group has some pending polls, assign the next poll to a group randomly
    //     according to the weights.
    repeated temporal.api.taskqueue.v1.PollerGroupInfo poller_group_infos = 18;
}

message RespondWorkflowTaskCompletedRequest {
    // The task token as received in `PollWorkflowTaskQueueResponse`
    bytes task_token = 1;
    // A list of commands generated when driving the workflow code in response to the new task
    repeated temporal.api.command.v1.Command commands = 2;
    // The identity of the worker/client
    string identity = 3;
    // May be set by workers to indicate that the worker desires future tasks to be provided with
    // incremental history on a sticky queue.
    temporal.api.taskqueue.v1.StickyExecutionAttributes sticky_attributes = 4;
    // If set, the worker wishes to immediately receive the next workflow task as a response to
    // this completion. This can save on polling round-trips.
    bool return_new_workflow_task = 5;
    // Can be used to *force* creation of a new workflow task, even if no commands have resolved or
    // one would not otherwise have been generated. This is used when the worker knows it is doing
    // something useful, but cannot complete it within the workflow task timeout. Local activities
    // which run for longer than the task timeout being the prime example.
    bool force_create_new_workflow_task = 6;
    // Deprecated. Use `deployment_options` instead.
    // Worker process' unique binary id
    string binary_checksum = 7 [deprecated = true];
    // Responses to the `queries` field in the task being responded to
    map<string, temporal.api.query.v1.WorkflowQueryResult> query_results = 8;
    string namespace = 9;
    // Resource ID for routing. Contains the workflow ID from the original task.
    string resource_id = 18;
    // Version info of the worker who processed this task. This message's `build_id` field should
    // always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
    // field to true. See message docstrings for more.
    // Deprecated. Use `deployment_options` and `versioning_behavior` instead.
    temporal.api.common.v1.WorkerVersionStamp worker_version_stamp = 10 [deprecated = true];
    // Protocol messages piggybacking on a WFT as a transport
    repeated temporal.api.protocol.v1.Message messages = 11;
    // Data the SDK wishes to record for itself, but server need not interpret, and does not
    // directly impact workflow state.
    temporal.api.sdk.v1.WorkflowTaskCompletedMetadata sdk_metadata = 12;
    // Local usage data collected for metering
    temporal.api.common.v1.MeteringMetadata metering_metadata = 13;
    // All capabilities the SDK supports.
    Capabilities capabilities = 14;
    // Deployment info of the worker that completed this task. Must be present if user has set
    // `WorkerDeploymentOptions` regardless of versioning being enabled or not.
    // Deprecated. Replaced with `deployment_options`.
    temporal.api.deployment.v1.Deployment deployment = 15 [deprecated = true];
    // Versioning behavior of this workflow execution as set on the worker that completed this task.
    // UNSPECIFIED means versioning is not enabled in the worker.
    temporal.api.enums.v1.VersioningBehavior versioning_behavior = 16;
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 17;

    // A unique key for this worker instance, used for tracking worker lifecycle.
    // This is guaranteed to be unique, whereas identity is not guaranteed to be unique.
    string worker_instance_key = 19;

    // A dedicated per-worker Nexus task queue on which the server sends control
    // tasks (e.g. activity cancellation) to this specific worker instance.
    string worker_control_task_queue = 20;

    // SDK capability details.
    message Capabilities {
        // True if the SDK can handle speculative workflow task with command events. If true, the
        // server may choose, at its discretion, to discard a speculative workflow task even if that
        // speculative task included command events the SDK had not previously processed.
        //
        // (-- api-linter: core::0140::prepositions=disabled
        //     aip.dev/not-precedent: "with" used to describe the workflow task. --)
        bool discard_speculative_workflow_task_with_events = 1;
    }
}

message RespondWorkflowTaskCompletedResponse {
    // See `RespondWorkflowTaskCompletedResponse::return_new_workflow_task`
    PollWorkflowTaskQueueResponse workflow_task = 1;
    // See `ScheduleActivityTaskCommandAttributes::request_eager_execution`
    repeated PollActivityTaskQueueResponse activity_tasks = 2;
    // If non zero, indicates the server has discarded the workflow task that was being responded to.
    // Will be the event ID of the last workflow task started event in the history before the new workflow task.
    // Server is only expected to discard a workflow task if it could not have modified the workflow state.
    int64 reset_history_event_id = 3;
}

message RespondWorkflowTaskFailedRequest {
    // The task token as received in `PollWorkflowTaskQueueResponse`
    bytes task_token = 1;
    // Why did the task fail? It's important to note that many of the variants in this enum cannot
    // apply to worker responses. See the type's doc for more.
    temporal.api.enums.v1.WorkflowTaskFailedCause cause = 2;
    // Failure details
    temporal.api.failure.v1.Failure failure = 3;
    // The identity of the worker/client
    string identity = 4;
    // Deprecated. Use `deployment_options` instead.
    // Worker process' unique binary id
    string binary_checksum = 5 [deprecated = true];
    string namespace = 6;
    // Resource ID for routing. Contains the workflow ID from the original task.
    string resource_id = 11;
    // Protocol messages piggybacking on a WFT as a transport
    repeated temporal.api.protocol.v1.Message messages = 7;
    // Version info of the worker who processed this task. This message's `build_id` field should
    // always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
    // field to true. See message docstrings for more.
    // Deprecated. Use `deployment_options` instead.
    temporal.api.common.v1.WorkerVersionStamp worker_version = 8 [deprecated = true];
    // Deployment info of the worker that completed this task. Must be present if user has set
    // `WorkerDeploymentOptions` regardless of versioning being enabled or not.
    // Deprecated. Replaced with `deployment_options`.
    temporal.api.deployment.v1.Deployment deployment = 9 [deprecated = true];
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 10;
}

message RespondWorkflowTaskFailedResponse {
}

message PollActivityTaskQueueRequest {
    string namespace = 1;
    temporal.api.taskqueue.v1.TaskQueue task_queue = 2;
    // Unless this is the first poll, the client must pass one of the poller group IDs received in
    // `poller_group_infos` of the last the PollActivityTaskQueueResponse according to the
    // instructions. If not set, the poll is routed randomly which can cause it being blocked
    // without receiving a task while the queue actually has tasks in another server location.
    string poller_group_id = 10;
    // The identity of the worker/client
    string identity = 3;
    // A unique key for this worker instance, used for tracking worker lifecycle.
    // This is guaranteed to be unique, whereas identity is not guaranteed to be unique.
    string worker_instance_key = 8;

    // A dedicated per-worker Nexus task queue on which the server sends control
    // tasks (e.g. activity cancellation) to this specific worker instance.
    string worker_control_task_queue = 9;

    temporal.api.taskqueue.v1.TaskQueueMetadata task_queue_metadata = 4;
    // Information about this worker's build identifier and if it is choosing to use the versioning
    // feature. See the `WorkerVersionCapabilities` docstring for more.
    // Deprecated. Replaced by deployment_options.
    temporal.api.common.v1.WorkerVersionCapabilities worker_version_capabilities = 5 [deprecated = true];
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 6;

    // Removed in 1.55.0; was temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat
    reserved 7;
    reserved "worker_heartbeat";
}

message PollActivityTaskQueueResponse {
    // A unique identifier for this task
    bytes task_token = 1;
    // The namespace of the activity. If this is a workflow activity then this is the namespace of
    // the workflow also. If this is a standalone activity then the name of this field is
    // misleading, but retained for compatibility with workflow activities.
    string workflow_namespace = 2;
    // Type of the requesting workflow (if this is a workflow activity).
    temporal.api.common.v1.WorkflowType workflow_type = 3;
    // Execution info of the requesting workflow (if this is a workflow activity)
    temporal.api.common.v1.WorkflowExecution workflow_execution = 4;
    temporal.api.common.v1.ActivityType activity_type = 5;
    // The autogenerated or user specified identifier of this activity. Can be used to complete the
    // activity via `RespondActivityTaskCompletedById`. May be re-used as long as the last usage
    // has resolved, but unique IDs for every activity invocation is a good idea.
    // Note that only a workflow activity ID may be autogenerated.
    string activity_id = 6;
    // Headers specified by the scheduling workflow. Commonly used to propagate contextual info
    // from the workflow to its activities. For example, tracing contexts.
    temporal.api.common.v1.Header header = 7;
    // Arguments to the activity invocation
    temporal.api.common.v1.Payloads input = 8;
    // Details of the last heartbeat that was recorded for this activity as of the time this task
    // was delivered.
    temporal.api.common.v1.Payloads heartbeat_details = 9;
    // When was this task first scheduled
    google.protobuf.Timestamp scheduled_time = 10;
    // When was this task attempt scheduled
    google.protobuf.Timestamp current_attempt_scheduled_time = 11;
    // When was this task started (this attempt)
    google.protobuf.Timestamp started_time = 12;
    // Starting at 1, the number of attempts to perform this activity
    int32 attempt = 13;
    // First scheduled -> final result reported timeout
    //
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "to" is used to indicate interval. --)
    google.protobuf.Duration schedule_to_close_timeout = 14;
    // Current attempt start -> final result reported timeout
    //
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "to" is used to indicate interval. --)
    google.protobuf.Duration start_to_close_timeout = 15;
    // Window within which the activity must report a heartbeat, or be timed out.
    google.protobuf.Duration heartbeat_timeout = 16;
    // This is the retry policy the service uses which may be different from the one provided
    // (or not) during activity scheduling. The service can override the provided one if some
    // values are not specified or exceed configured system limits.
    temporal.api.common.v1.RetryPolicy retry_policy = 17;
    // Server-advised information the SDK may use to adjust its poller count.
    temporal.api.taskqueue.v1.PollerScalingDecision poller_scaling_decision = 18;
    // Priority metadata
    temporal.api.common.v1.Priority priority = 19;
    // The run ID of the activity execution, only set for standalone activities.
    string activity_run_id = 20;
    // The weighted list of poller groups IDs that client should use for future polls to this task
    // queue. Client is expected to:
    //   1. Maintain minimum number of pollers no less than the number of groups.
    //   2. Try to assign the next poll to a group without any pending polls,
    //   3. If every group has some pending polls, assign the next poll to a group randomly
    //     according to the weights.
    repeated temporal.api.taskqueue.v1.PollerGroupInfo poller_group_infos = 21;
}

message RecordActivityTaskHeartbeatRequest {
    // The task token as received in `PollActivityTaskQueueResponse`
    bytes task_token = 1;
    // Arbitrary data, of which the most recent call is kept, to store for this activity
    temporal.api.common.v1.Payloads details = 2;
    // The identity of the worker/client
    string identity = 3;
    string namespace = 4;
    // Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
    string resource_id = 5;
}

message RecordActivityTaskHeartbeatResponse {
    // Will be set to true if the activity has been asked to cancel itself. The SDK should then
    // notify the activity of cancellation if it is still running.
    bool cancel_requested = 1;

    // Will be set to true if the activity is paused.
    bool activity_paused = 2;

    // Will be set to true if the activity was reset.
    // Applies only to the current run.
    bool activity_reset = 3;
}

message RecordActivityTaskHeartbeatByIdRequest {
    // Namespace of the workflow which scheduled this activity
    string namespace = 1;
    // Id of the workflow which scheduled this activity, leave empty to target a standalone activity
    string workflow_id = 2;
    // For a workflow activity - the run ID of the workflow which scheduled this activity.
    // For a standalone activity - the run ID of the activity.
    string run_id = 3;
    // Id of the activity we're heartbeating
    string activity_id = 4;
    // Arbitrary data, of which the most recent call is kept, to store for this activity
    temporal.api.common.v1.Payloads details = 5;
    // The identity of the worker/client
    string identity = 6;
    // Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
    string resource_id = 7;
}

message RecordActivityTaskHeartbeatByIdResponse {
    // Will be set to true if the activity has been asked to cancel itself. The SDK should then
    // notify the activity of cancellation if it is still running.
    bool cancel_requested = 1;

    // Will be set to true if the activity is paused.
    bool activity_paused = 2;

    // Will be set to true if the activity was reset.
    // Applies only to the current run.
    bool activity_reset = 3;
}

message RespondActivityTaskCompletedRequest {
    // The task token as received in `PollActivityTaskQueueResponse`
    bytes task_token = 1;
    // The result of successfully executing the activity
    temporal.api.common.v1.Payloads result = 2;
    // The identity of the worker/client
    string identity = 3;
    string namespace = 4;
    // Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
    string resource_id = 8;
    // Version info of the worker who processed this task. This message's `build_id` field should
    // always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
    // field to true. See message docstrings for more.
    // Deprecated. Use `deployment_options` instead.
    temporal.api.common.v1.WorkerVersionStamp worker_version = 5 [deprecated = true];
    // Deployment info of the worker that completed this task. Must be present if user has set
    // `WorkerDeploymentOptions` regardless of versioning being enabled or not.
    // Deprecated. Replaced with `deployment_options`.
    temporal.api.deployment.v1.Deployment deployment = 6 [deprecated = true];
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 7;
}

message RespondActivityTaskCompletedResponse {
}

message RespondActivityTaskCompletedByIdRequest {
    // Namespace of the workflow which scheduled this activity
    string namespace = 1;
    // Id of the workflow which scheduled this activity, leave empty to target a standalone activity
    string workflow_id = 2;
    // For a workflow activity - the run ID of the workflow which scheduled this activity.
    // For a standalone activity - the run ID of the activity.
    string run_id = 3;
    // Id of the activity to complete
    string activity_id = 4;
    // The serialized result of activity execution
    temporal.api.common.v1.Payloads result = 5;
    // The identity of the worker/client
    string identity = 6;
    // Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
    string resource_id = 7;
}

message RespondActivityTaskCompletedByIdResponse {
}

message RespondActivityTaskFailedRequest {
    // The task token as received in `PollActivityTaskQueueResponse`
    bytes task_token = 1;
    // Detailed failure information
    temporal.api.failure.v1.Failure failure = 2;
    // The identity of the worker/client
    string identity = 3;
    string namespace = 4;
    // Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
    string resource_id = 9;
    // Additional details to be stored as last activity heartbeat
    temporal.api.common.v1.Payloads last_heartbeat_details = 5;
    // Version info of the worker who processed this task. This message's `build_id` field should
    // always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
    // field to true. See message docstrings for more.
    // Deprecated. Use `deployment_options` instead.
    temporal.api.common.v1.WorkerVersionStamp worker_version = 6 [deprecated = true];
    // Deployment info of the worker that completed this task. Must be present if user has set
    // `WorkerDeploymentOptions` regardless of versioning being enabled or not.
    // Deprecated. Replaced with `deployment_options`.
    temporal.api.deployment.v1.Deployment deployment = 7 [deprecated = true];
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 8;
}

message RespondActivityTaskFailedResponse {
    // Server validation failures could include
    // last_heartbeat_details payload is too large, request failure is too large
    repeated temporal.api.failure.v1.Failure failures = 1;
}

message RespondActivityTaskFailedByIdRequest {
    // Namespace of the workflow which scheduled this activity
    string namespace = 1;
    // Id of the workflow which scheduled this activity, leave empty to target a standalone activity
    string workflow_id = 2;
    // For a workflow activity - the run ID of the workflow which scheduled this activity.
    // For a standalone activity - the run ID of the activity.
    string run_id = 3;
    // Id of the activity to fail
    string activity_id = 4;
    // Detailed failure information
    temporal.api.failure.v1.Failure failure = 5;
    // The identity of the worker/client
    string identity = 6;
    // Additional details to be stored as last activity heartbeat
    temporal.api.common.v1.Payloads last_heartbeat_details = 7;
    // Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
    string resource_id = 8;
}

message RespondActivityTaskFailedByIdResponse {
    // Server validation failures could include
    // last_heartbeat_details payload is too large, request failure is too large
    repeated temporal.api.failure.v1.Failure failures = 1;
}

message RespondActivityTaskCanceledRequest {
    // The task token as received in `PollActivityTaskQueueResponse`
    bytes task_token = 1;
    // Serialized additional information to attach to the cancellation
    temporal.api.common.v1.Payloads details = 2;
    // The identity of the worker/client
    string identity = 3;
    string namespace = 4;
    // Resource ID for routing. Contains the workflow ID or activity ID for standalone activities.
    string resource_id = 8;
    // Version info of the worker who processed this task. This message's `build_id` field should
    // always be set by SDKs. Workers opting into versioning will also set the `use_versioning`
    // field to true. See message docstrings for more.
    // Deprecated. Use `deployment_options` instead.
    temporal.api.common.v1.WorkerVersionStamp worker_version = 5 [deprecated = true];
    // Deployment info of the worker that completed this task. Must be present if user has set
    // `WorkerDeploymentOptions` regardless of versioning being enabled or not.
    // Deprecated. Replaced with `deployment_options`.
    temporal.api.deployment.v1.Deployment deployment = 6 [deprecated = true];
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 7;
}

message RespondActivityTaskCanceledResponse {
}

message RespondActivityTaskCanceledByIdRequest {
    // Namespace of the workflow which scheduled this activity
    string namespace = 1;
    // Id of the workflow which scheduled this activity, leave empty to target a standalone activity
    string workflow_id = 2;
    // For a workflow activity - the run ID of the workflow which scheduled this activity.
    // For a standalone activity - the run ID of the activity.
    string run_id = 3;
    // Id of the activity to confirm is cancelled
    string activity_id = 4;
    // Serialized additional information to attach to the cancellation
    temporal.api.common.v1.Payloads details = 5;
    // The identity of the worker/client
    string identity = 6;
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 7;
    // Resource ID for routing. Contains "workflow:workflow_id" or "activity:activity_id" for standalone activities.
    string resource_id = 8;
}

message RespondActivityTaskCanceledByIdResponse {
}

message RequestCancelWorkflowExecutionRequest {
    string namespace = 1;
    temporal.api.common.v1.WorkflowExecution workflow_execution = 2;
    // The identity of the worker/client
    string identity = 3;
    // Used to de-dupe cancellation requests
    string request_id = 4;
    // If set, this call will error if the most recent (if no run id is set on
    // `workflow_execution`), or specified (if it is) workflow execution is not part of the same
    // execution chain as this id.
    string first_execution_run_id = 5;
    // Reason for requesting the cancellation
    string reason = 6;
    // Links to be associated with the WorkflowExecutionCanceled event.
    repeated temporal.api.common.v1.Link links = 7;
}

message RequestCancelWorkflowExecutionResponse {
}

// Keep the parameters in sync with:
//   - temporal.api.batch.v1.BatchOperationSignal.
//   - temporal.api.workflow.v1.PostResetOperation.SignalWorkflow.
message SignalWorkflowExecutionRequest {
    string namespace = 1;
    temporal.api.common.v1.WorkflowExecution workflow_execution = 2;
    // The workflow author-defined name of the signal to send to the workflow
    string signal_name = 3;
    // Serialized value(s) to provide with the signal
    temporal.api.common.v1.Payloads input = 4;
    // The identity of the worker/client
    string identity = 5;
    // Used to de-dupe sent signals
    string request_id = 6;
    // Deprecated.
    string control = 7 [deprecated = true];
    // Headers that are passed with the signal to the processing workflow.
    // These can include things like auth or tracing tokens.
    temporal.api.common.v1.Header header = 8;
    reserved 9;

    // Links to be associated with the WorkflowExecutionSignaled event.
    repeated temporal.api.common.v1.Link links = 10;
}

message SignalWorkflowExecutionResponse {
    // Link to be associated with the WorkflowExecutionSignaled event.
    // Added on the response to propagate the backlink.
    // Available from Temporal server 1.31 and up.
    temporal.api.common.v1.Link link = 1;
}

message SignalWithStartWorkflowExecutionRequest {
    string namespace = 1;
    string workflow_id = 2;
    temporal.api.common.v1.WorkflowType workflow_type = 3;
    // The task queue to start this workflow on, if it will be started
    temporal.api.taskqueue.v1.TaskQueue task_queue = 4;
    // Serialized arguments to the workflow. These are passed as arguments to the workflow function.
    temporal.api.common.v1.Payloads input = 5;
    // Total workflow execution timeout including retries and continue as new
    google.protobuf.Duration workflow_execution_timeout = 6;
    // Timeout of a single workflow run
    google.protobuf.Duration workflow_run_timeout = 7;
    // Timeout of a single workflow task
    google.protobuf.Duration workflow_task_timeout = 8;
    // The identity of the worker/client
    string identity = 9;
    // Used to de-dupe signal w/ start requests
    string request_id = 10;
    // Defines whether to allow re-using the workflow id from a previously *closed* workflow.
    // The default policy is WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE.
    //
    // See `workflow_id_reuse_policy` for handling a workflow id duplication with a *running* workflow.
    temporal.api.enums.v1.WorkflowIdReusePolicy workflow_id_reuse_policy = 11;
    // Defines how to resolve a workflow id conflict with a *running* workflow.
    // The default policy is WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING.
    // Note that WORKFLOW_ID_CONFLICT_POLICY_FAIL is an invalid option.
    //
    // See `workflow_id_reuse_policy` for handling a workflow id duplication with a *closed* workflow.
    temporal.api.enums.v1.WorkflowIdConflictPolicy workflow_id_conflict_policy = 22;
    // The workflow author-defined name of the signal to send to the workflow
    string signal_name = 12;
    // Serialized value(s) to provide with the signal
    temporal.api.common.v1.Payloads signal_input = 13;
    // Deprecated.
    string control = 14 [deprecated = true];
    // Retry policy for the workflow
    temporal.api.common.v1.RetryPolicy retry_policy = 15;
    // See https://docs.temporal.io/docs/content/what-is-a-temporal-cron-job/
    string cron_schedule = 16;
    temporal.api.common.v1.Memo memo = 17;
    temporal.api.common.v1.SearchAttributes search_attributes = 18;
    temporal.api.common.v1.Header header = 19;
    // Time to wait before dispatching the first workflow task. Cannot be used with `cron_schedule`.
    // Note that the signal will be delivered with the first workflow task. If the workflow gets
    // another SignalWithStartWorkflow before the delay a workflow task will be dispatched immediately
    // and the rest of the delay period will be ignored, even if that request also had a delay.
    // Signal via SignalWorkflowExecution will not unblock the workflow.
    google.protobuf.Duration workflow_start_delay = 20;
    reserved 21;
    // Metadata on the workflow if it is started. This is carried over to the WorkflowExecutionInfo
    // for use by user interfaces to display the fixed as-of-start summary and details of the
    // workflow.
    temporal.api.sdk.v1.UserMetadata user_metadata = 23;

    // Links to be associated with the WorkflowExecutionStarted and WorkflowExecutionSignaled events.
    repeated temporal.api.common.v1.Link links = 24;
    // If set, takes precedence over the Versioning Behavior sent by the SDK on Workflow Task completion.
    // To unset the override after the workflow is running, use UpdateWorkflowExecutionOptions.
    temporal.api.workflow.v1.VersioningOverride versioning_override = 25;
    // Priority metadata
    temporal.api.common.v1.Priority priority = 26;
    // Time-skipping configuration. If not set, time skipping is disabled.
    temporal.api.workflow.v1.TimeSkippingConfig time_skipping_config = 27;
}

message SignalWithStartWorkflowExecutionResponse {
    // The run id of the workflow that was started - or just signaled, if it was already running.
    string run_id = 1;
    // If true, a new workflow was started.
    bool started = 2;
    // Link to be associated with the WorkflowExecutionSignaled event.
    // Added on the response to propagate the backlink.
    // Available from Temporal server 1.31 and up.
    temporal.api.common.v1.Link signal_link = 3;
}

message ResetWorkflowExecutionRequest {
    string namespace = 1;
    // The workflow to reset. If this contains a run ID then the workflow will be reset back to the
    // provided event ID in that run. Otherwise it will be reset to the provided event ID in the
    // current run. In all cases the current run will be terminated and a new run started.
    temporal.api.common.v1.WorkflowExecution workflow_execution = 2;
    string reason = 3;
    // The id of a `WORKFLOW_TASK_COMPLETED`,`WORKFLOW_TASK_TIMED_OUT`, `WORKFLOW_TASK_FAILED`, or
    // `WORKFLOW_TASK_STARTED` event to reset to.
    int64 workflow_task_finish_event_id = 4;
    // Used to de-dupe reset requests
    string request_id = 5;
    // Deprecated. Use `options`.
    // Default: RESET_REAPPLY_TYPE_SIGNAL
    temporal.api.enums.v1.ResetReapplyType reset_reapply_type = 6 [deprecated = true];
    // Event types not to be reapplied
    repeated temporal.api.enums.v1.ResetReapplyExcludeType reset_reapply_exclude_types = 7;
    // Operations to perform after the workflow has been reset. These operations will be applied
    // to the *new* run of the workflow execution in the order they are provided.
    // All operations are applied to the workflow before the first new workflow task is generated
    repeated temporal.api.workflow.v1.PostResetOperation post_reset_operations = 8;
    // The identity of the worker/client
    string identity = 9;
}

message ResetWorkflowExecutionResponse {
    string run_id = 1;
}

message TerminateWorkflowExecutionRequest {
    string namespace = 1;
    temporal.api.common.v1.WorkflowExecution workflow_execution = 2;
    string reason = 3;
    // Serialized additional information to attach to the termination event
    temporal.api.common.v1.Payloads details = 4;
    // The identity of the worker/client
    string identity = 5;
    // If set, this call will error if the most recent (if no run id is set on
    // `workflow_execution`), or specified (if it is) workflow execution is not part of the same
    // execution chain as this id.
    string first_execution_run_id = 6;

    // Links to be associated with the WorkflowExecutionTerminated event.
    repeated temporal.api.common.v1.Link links = 7;
}

message TerminateWorkflowExecutionResponse {
}

message DeleteWorkflowExecutionRequest {
    string namespace = 1;
    // Workflow Execution to delete. If run_id is not specified, the latest one is used.
    temporal.api.common.v1.WorkflowExecution workflow_execution = 2;
}

message DeleteWorkflowExecutionResponse {
}

message ListOpenWorkflowExecutionsRequest {
    string namespace = 1;
    int32 maximum_page_size = 2;
    bytes next_page_token = 3;
    temporal.api.filter.v1.StartTimeFilter start_time_filter = 4;
    oneof filters {
        temporal.api.filter.v1.WorkflowExecutionFilter execution_filter = 5;
        temporal.api.filter.v1.WorkflowTypeFilter type_filter = 6;
    }
}

message ListOpenWorkflowExecutionsResponse {
    repeated temporal.api.workflow.v1.WorkflowExecutionInfo executions = 1;
    bytes next_page_token = 2;
}

message ListClosedWorkflowExecutionsRequest {
    string namespace = 1;
    int32 maximum_page_size = 2;
    bytes next_page_token = 3;
    temporal.api.filter.v1.StartTimeFilter start_time_filter = 4;
    oneof filters {
        temporal.api.filter.v1.WorkflowExecutionFilter execution_filter = 5;
        temporal.api.filter.v1.WorkflowTypeFilter type_filter = 6;
        temporal.api.filter.v1.StatusFilter status_filter = 7;
    }
}

message ListClosedWorkflowExecutionsResponse {
    repeated temporal.api.workflow.v1.WorkflowExecutionInfo executions = 1;
    bytes next_page_token = 2;
}

message ListWorkflowExecutionsRequest {
    string namespace = 1;
    int32 page_size = 2;
    bytes next_page_token = 3;
    string query = 4;
}

message ListWorkflowExecutionsResponse {
    repeated temporal.api.workflow.v1.WorkflowExecutionInfo executions = 1;
    bytes next_page_token = 2;
}

message ListArchivedWorkflowExecutionsRequest {
    string namespace = 1;
    int32 page_size = 2;
    bytes next_page_token = 3;
    string query = 4;
}

message ListArchivedWorkflowExecutionsResponse {
    repeated temporal.api.workflow.v1.WorkflowExecutionInfo executions = 1;
    bytes next_page_token = 2;
}

// Deprecated: Use with `ListWorkflowExecutions`.
message ScanWorkflowExecutionsRequest {
    string namespace = 1;
    int32 page_size = 2;
    bytes next_page_token = 3;
    string query = 4;
}

// Deprecated: Use with `ListWorkflowExecutions`.
message ScanWorkflowExecutionsResponse {
    repeated temporal.api.workflow.v1.WorkflowExecutionInfo executions = 1;
    bytes next_page_token = 2;
}

message CountWorkflowExecutionsRequest {
    string namespace = 1;
    string query = 2;
}

message CountWorkflowExecutionsResponse {
    // If `query` is not grouping by any field, the count is an approximate number
    // of workflows that matches the query.
    // If `query` is grouping by a field, the count is simply the sum of the counts
    // of the groups returned in the response. This number can be smaller than the
    // total number of workflows matching the query.
    int64 count = 1;

    // `groups` contains the groups if the request is grouping by a field.
    // The list might not be complete, and the counts of each group is approximate.
    repeated AggregationGroup groups = 2;

    message AggregationGroup {
        repeated temporal.api.common.v1.Payload group_values = 1;
        int64 count = 2;
    }
}

message GetSearchAttributesRequest {
}

message GetSearchAttributesResponse {
    map<string, temporal.api.enums.v1.IndexedValueType> keys = 1;
}

message RespondQueryTaskCompletedRequest {
    bytes task_token = 1;
    temporal.api.enums.v1.QueryResultType completed_type = 2;
    // The result of the query.
    // Mutually exclusive with `error_message` and `failure`. Set when the query succeeds.
    temporal.api.common.v1.Payloads query_result = 3;
    // A plain error message that must be set if completed_type is QUERY_RESULT_TYPE_FAILED.
    // SDKs should also fill in the more complete `failure` field to provide the full context and
    // support encryption of failure information.
    // `error_message` will be duplicated if the `failure` field is present to support callers
    // that pre-date the addition of that field, regardless of whether or not a custom failure
    // converter is used.
    // Mutually exclusive with `query_result`. Set when the query fails.
    string error_message = 4;
    reserved 5;
    string namespace = 6;
    // The full reason for this query failure. This field is newer than `error_message` and can be
    // encoded by the SDK's failure converter to support E2E encryption of messages and stack
    // traces.
    // Mutually exclusive with `query_result`. Set when the query fails.
    temporal.api.failure.v1.Failure failure = 7;
    // Why did the task fail? It's important to note that many of the variants in this enum cannot
    // apply to worker responses. See the type's doc for more.
    temporal.api.enums.v1.WorkflowTaskFailedCause cause = 8;
    // Client must forward the poller_group_id received in PollWorkflowTaskQueueResponse for proper
    // routing of the response.
    string poller_group_id = 9;
}

message RespondQueryTaskCompletedResponse {
}

message ResetStickyTaskQueueRequest {
    string namespace = 1;
    temporal.api.common.v1.WorkflowExecution execution = 2;
}

message ResetStickyTaskQueueResponse {
}

message ShutdownWorkerRequest {
    string namespace = 1;
    // sticky_task_queue may not always be populated. We want to ensure all workers
    // send a shutdown request to update worker state for heartbeating, as well
    // as cancel pending poll calls early, instead of waiting for timeouts.
    string sticky_task_queue = 2;
    string identity = 3;
    string reason = 4;
    temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 5;
    // Technically this is also sent in the WorkerHeartbeat, but
    // since worker heartbeating can be turned off, this needs
    // to be a separate, top-level field.
    string worker_instance_key = 6;
    // Task queue name the worker is polling on. This allows server to cancel
    // all outstanding poll RPC calls from SDK. This avoids a race condition that
    // can lead to tasks being lost.
    string task_queue = 7;
    // Task queue types that help server cancel outstanding poll RPC
    // calls from SDK. This avoids a race condition that can lead to tasks being lost.
    repeated temporal.api.enums.v1.TaskQueueType task_queue_types = 8;
}

message ShutdownWorkerResponse {
}

message QueryWorkflowRequest {
    string namespace = 1;
    temporal.api.common.v1.WorkflowExecution execution = 2;
    temporal.api.query.v1.WorkflowQuery query = 3;
    // QueryRejectCondition can used to reject the query if workflow state does not satisfy condition.
    // Default: QUERY_REJECT_CONDITION_NONE.
    temporal.api.enums.v1.QueryRejectCondition query_reject_condition = 4;
}

message QueryWorkflowResponse {
    temporal.api.common.v1.Payloads query_result = 1;
    temporal.api.query.v1.QueryRejected query_rejected = 2;
}

message DescribeWorkflowExecutionRequest {
    string namespace = 1;
    temporal.api.common.v1.WorkflowExecution execution = 2;
}

message DescribeWorkflowExecutionResponse {
    temporal.api.workflow.v1.WorkflowExecutionConfig execution_config = 1;
    temporal.api.workflow.v1.WorkflowExecutionInfo workflow_execution_info = 2;
    repeated temporal.api.workflow.v1.PendingActivityInfo pending_activities = 3;
    repeated temporal.api.workflow.v1.PendingChildExecutionInfo pending_children = 4;
    temporal.api.workflow.v1.PendingWorkflowTaskInfo pending_workflow_task = 5;
    repeated temporal.api.workflow.v1.CallbackInfo callbacks = 6;
    repeated temporal.api.workflow.v1.PendingNexusOperationInfo pending_nexus_operations = 7;
    temporal.api.workflow.v1.WorkflowExecutionExtendedInfo workflow_extended_info = 8;
}

// (-- api-linter: core::0203::optional=disabled
//     aip.dev/not-precedent: field_behavior annotation not available in our gogo fork --)
message DescribeTaskQueueRequest {
    string namespace = 1;

    // Sticky queues are not supported in deprecated ENHANCED mode.
    temporal.api.taskqueue.v1.TaskQueue task_queue = 2;

    // If unspecified (TASK_QUEUE_TYPE_UNSPECIFIED), then default value (TASK_QUEUE_TYPE_WORKFLOW) will be used.
    // Only supported in default mode (use `task_queue_types` in ENHANCED mode instead).
    temporal.api.enums.v1.TaskQueueType task_queue_type = 3;

    // Report stats for the requested task queue type(s).
    bool report_stats = 8;

    // Report Task Queue Config
    bool report_config = 11;

    // Deprecated, use `report_stats` instead.
    // If true, the task queue status will be included in the response.
    bool include_task_queue_status = 4 [deprecated = true];

    // Deprecated. ENHANCED mode is also being deprecated.
    // Select the API mode to use for this request: DEFAULT mode (if unset) or ENHANCED mode.
    // Consult the documentation for each field to understand which mode it is supported in.
    temporal.api.enums.v1.DescribeTaskQueueMode api_mode = 5 [deprecated = true];

    // Deprecated (as part of the ENHANCED mode deprecation).
    // Optional. If not provided, the result for the default Build ID will be returned. The default Build ID is the one
    // mentioned in the first unconditional Assignment Rule. If there is no default Build ID, the result for the
    // unversioned queue will be returned.
    // (-- api-linter: core::0140::prepositions --)
    temporal.api.taskqueue.v1.TaskQueueVersionSelection versions = 6 [deprecated = true];

    // Deprecated (as part of the ENHANCED mode deprecation).
    // Task queue types to report info about. If not specified, all types are considered.
    repeated temporal.api.enums.v1.TaskQueueType task_queue_types = 7 [deprecated = true];

    // Deprecated (as part of the ENHANCED mode deprecation).
    // Report list of pollers for requested task queue types and versions.
    bool report_pollers = 9 [deprecated = true];

    // Deprecated (as part of the ENHANCED mode deprecation).
    // Report task reachability for the requested versions and all task types (task reachability is not reported
    // per task type).
    bool report_task_reachability = 10 [deprecated = true];
}

message DescribeTaskQueueResponse {
    repeated temporal.api.taskqueue.v1.PollerInfo pollers = 1;

    // Statistics for the task queue.
    // Only set if `report_stats` is set on the request.
    temporal.api.taskqueue.v1.TaskQueueStats stats = 5;

    // Task queue stats breakdown by priority key. Only contains actively used priority keys.
    // Only set if `report_stats` is set on the request.
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "by" is used to clarify the keys and values. --)
    map<int32, temporal.api.taskqueue.v1.TaskQueueStats> stats_by_priority_key = 8;

    // Specifies which Worker Deployment Version(s) Server routes this Task Queue's tasks to.
    // When not present, it means the tasks are routed to Unversioned workers (workers with
    // UNVERSIONED or unspecified WorkerVersioningMode.)
    // Task Queue Versioning info is updated indirectly by calling SetWorkerDeploymentCurrentVersion
    // and SetWorkerDeploymentRampingVersion on Worker Deployments.
    // Note: This information is not relevant to Pinned workflow executions and their activities as
    // they are always routed to their Pinned Deployment Version. However, new workflow executions
    // are typically not Pinned until they complete their first task (unless they are started with
    // a Pinned VersioningOverride or are Child Workflows of a Pinned parent).
    temporal.api.taskqueue.v1.TaskQueueVersioningInfo versioning_info = 4;

    // Only populated if report_task_queue_config is set to true.
    temporal.api.taskqueue.v1.TaskQueueConfig config  = 6;

    message EffectiveRateLimit {
        // The effective rate limit for the task queue.
        float requests_per_second = 1;

        // Source of the RateLimit Configuration,which can be one of the following values:
        // - SOURCE_API: The rate limit that is set via the TaskQueueConfig api.
        // - SOURCE_WORKER: The rate limit is the value set using the workerOptions in TaskQueueActivitiesPerSecond.
        // - SOURCE_SYSTEM: The rate limit is the default value set by the system
        temporal.api.enums.v1.RateLimitSource rate_limit_source = 2;
    }

    EffectiveRateLimit effective_rate_limit = 7;

    // Deprecated.
    // Status of the task queue. Only populated when `include_task_queue_status` is set to true in the request.
    temporal.api.taskqueue.v1.TaskQueueStatus task_queue_status = 2 [deprecated = true];

    // Deprecated.
    // Only returned in ENHANCED mode.
    // This map contains Task Queue information for each Build ID. Empty string as key value means unversioned.
    map<string, temporal.api.taskqueue.v1.TaskQueueVersionInfo> versions_info = 3 [deprecated = true];
}

message GetClusterInfoRequest {
}

// GetClusterInfoResponse contains information about Temporal cluster.
message GetClusterInfoResponse {
    // Key is client name i.e "temporal-go", "temporal-java", or "temporal-cli".
    // Value is ranges of supported versions of this client i.e ">1.1.1 <=1.4.0 || ^5.0.0".
    map<string,string> supported_clients = 1;
    string server_version = 2;
    string cluster_id = 3;
    temporal.api.version.v1.VersionInfo version_info = 4;
    string cluster_name = 5;
    int32 history_shard_count = 6;
    string persistence_store = 7;
    string visibility_store = 8;
    int64 initial_failover_version = 9;
    int64 failover_version_increment = 10;
}

message GetSystemInfoRequest {
}

message GetSystemInfoResponse {
    // Version of the server.
    string server_version = 1;

    // All capabilities the system supports.
    Capabilities capabilities = 2;

    // System capability details.
    message Capabilities {
        // True if signal and query headers are supported.
        bool signal_and_query_header = 1;

        // True if internal errors are differentiated from other types of errors for purposes of
        // retrying non-internal errors.
        //
        // When unset/false, clients retry all failures. When true, clients should only retry
        // non-internal errors.
        bool internal_error_differentiation = 2;

        // True if RespondActivityTaskFailed API supports including heartbeat details
        bool activity_failure_include_heartbeat = 3;

        // Supports scheduled workflow features.
        bool supports_schedules = 4;

        // True if server uses protos that include temporal.api.failure.v1.Failure.encoded_attributes
        bool encoded_failure_attributes = 5;

        // True if server supports dispatching Workflow and Activity tasks based on a worker's build_id
        // (see:
        // https://github.com/temporalio/proposals/blob/a123af3b559f43db16ea6dd31870bfb754c4dc5e/versioning/worker-versions.md)
        bool build_id_based_versioning = 6;

        // True if server supports upserting workflow memo
        bool upsert_memo = 7;

        // True if server supports eager workflow task dispatching for the StartWorkflowExecution API
        bool eager_workflow_start = 8;

        // True if the server knows about the sdk metadata field on WFT completions and will record
        // it in history
        bool sdk_metadata = 9;

        // True if the server supports count group by execution status
        // (-- api-linter: core::0140::prepositions=disabled --)
        bool count_group_by_execution_status = 10;

        // True if the server supports Nexus operations.
        // This flag is dependent both on server version and for Nexus to be enabled via server configuration.
        bool nexus = 11;

        // True if the server supports server-scaled deployments.
        // This flag is dependent both on server version and for server-scaled deployments
        // to be enabled via server configuration.
        bool server_scaled_deployments = 12;

    }
}

message ListTaskQueuePartitionsRequest {
    string namespace = 1;
    temporal.api.taskqueue.v1.TaskQueue task_queue = 2;
}

message ListTaskQueuePartitionsResponse {
    repeated temporal.api.taskqueue.v1.TaskQueuePartitionMetadata activity_task_queue_partitions = 1;
    repeated temporal.api.taskqueue.v1.TaskQueuePartitionMetadata workflow_task_queue_partitions = 2;
}

// (-- api-linter: core::0203::optional=disabled
//     aip.dev/not-precedent: field_behavior annotation not available in our gogo fork --)
message CreateScheduleRequest {
    // The namespace the schedule should be created in.
    string namespace = 1;
    // The id of the new schedule.
    string schedule_id = 2;
    // The schedule spec, policies, action, and initial state.
    temporal.api.schedule.v1.Schedule schedule = 3;
    // Optional initial patch (e.g. to run the action once immediately).
    temporal.api.schedule.v1.SchedulePatch initial_patch = 4;
    // The identity of the client who initiated this request.
    string identity = 5;
    // A unique identifier for this create request for idempotence. Typically UUIDv4.
    string request_id = 6;
    // Memo and search attributes to attach to the schedule itself.
    temporal.api.common.v1.Memo memo = 7;
    temporal.api.common.v1.SearchAttributes search_attributes = 8;
}

message CreateScheduleResponse {
    bytes conflict_token = 1;
}

message DescribeScheduleRequest {
    // The namespace of the schedule to describe.
    string namespace = 1;
    // The id of the schedule to describe.
    string schedule_id = 2;
}

message DescribeScheduleResponse {
    // The complete current schedule details. This may not match the schedule as
    // created because:
    // - some types of schedule specs may get compiled into others (e.g.
    //   CronString into StructuredCalendarSpec)
    // - some unspecified fields may be replaced by defaults
    // - some fields in the state are modified automatically
    // - the schedule may have been modified by UpdateSchedule or PatchSchedule
    temporal.api.schedule.v1.Schedule schedule = 1;
    // Extra schedule state info.
    temporal.api.schedule.v1.ScheduleInfo info = 2;
    // The memo and search attributes that the schedule was created with.
    temporal.api.common.v1.Memo memo = 3;
    temporal.api.common.v1.SearchAttributes search_attributes = 4;

    // This value can be passed back to UpdateSchedule to ensure that the
    // schedule was not modified between a Describe and an Update, which could
    // lead to lost updates and other confusion.
    bytes conflict_token = 5;
}

message UpdateScheduleRequest {
    // The namespace of the schedule to update.
    string namespace = 1;
    // The id of the schedule to update.
    string schedule_id = 2;
    // The new schedule. The four main fields of the schedule (spec, action,
    // policies, state) are replaced completely by the values in this message.
    temporal.api.schedule.v1.Schedule schedule = 3;
    // This can be the value of conflict_token from a DescribeScheduleResponse,
    // which will cause this request to fail if the schedule has been modified
    // between the Describe and this Update.
    // If missing, the schedule will be updated unconditionally.
    bytes conflict_token = 4;
    // The identity of the client who initiated this request.
    string identity = 5;
    // A unique identifier for this update request for idempotence. Typically UUIDv4.
    string request_id = 6;
    // Schedule search attributes to be updated.
    // Do not set this field if you do not want to update the search attributes.
    // A non-null empty object will set the search attributes to an empty map.
    // Note: you cannot only update the search attributes with `UpdateScheduleRequest`,
    // you must also set the `schedule` field; otherwise, it will unset the schedule.
    temporal.api.common.v1.SearchAttributes search_attributes = 7;
    // Schedule memo to replace. If set, replaces the entire memo.
    // Do not set this field if you do not want to update the memo.
    // A non-null empty object will clear the memo.
    temporal.api.common.v1.Memo memo = 8;
}

message UpdateScheduleResponse {
}

message PatchScheduleRequest {
    // The namespace of the schedule to patch.
    string namespace = 1;
    // The id of the schedule to patch.
    string schedule_id = 2;
    temporal.api.schedule.v1.SchedulePatch patch = 3;
    // The identity of the client who initiated this request.
    string identity = 4;
    // A unique identifier for this update request for idempotence. Typically UUIDv4.
    string request_id = 5;
}

message PatchScheduleResponse {
}

message ListScheduleMatchingTimesRequest {
    // The namespace of the schedule to query.
    string namespace = 1;
    // The id of the schedule to query.
    string schedule_id = 2;
    // Time range to query.
    google.protobuf.Timestamp start_time = 3;
    google.protobuf.Timestamp end_time = 4;
}

message ListScheduleMatchingTimesResponse {
    repeated google.protobuf.Timestamp start_time = 1;
}

message DeleteScheduleRequest {
    // The namespace of the schedule to delete.
    string namespace = 1;
    // The id of the schedule to delete.
    string schedule_id = 2;
    // The identity of the client who initiated this request.
    string identity = 3;
}

message DeleteScheduleResponse {
}

message ListSchedulesRequest {
    // The namespace to list schedules in.
    string namespace = 1;
    // How many to return at once.
    int32 maximum_page_size = 2;
    // Token to get the next page of results.
    bytes next_page_token = 3;
    // Query to filter schedules.
    string query = 4;
}

message ListSchedulesResponse {
    repeated temporal.api.schedule.v1.ScheduleListEntry schedules = 1;
    bytes next_page_token = 2;
}

message CountSchedulesRequest {
    string namespace = 1;
    // Visibility query, see https://docs.temporal.io/list-filter for the syntax.
    string query = 2;
}

message CountSchedulesResponse {
    // If `query` is not grouping by any field, the count is an approximate number
    // of schedules that match the query.
    // If `query` is grouping by a field, the count is simply the sum of the counts
    // of the groups returned in the response. This number can be smaller than the
    // total number of schedules matching the query.
    int64 count = 1;

    // Contains the groups if the request is grouping by a field.
    // The list might not be complete, and the counts of each group is approximate.
    repeated AggregationGroup groups = 2;

    message AggregationGroup {
        repeated temporal.api.common.v1.Payload group_values = 1;
        int64 count = 2;
    }
}

// [cleanup-wv-pre-release]
message UpdateWorkerBuildIdCompatibilityRequest {
    message AddNewCompatibleVersion {
        // A new id to be added to an existing compatible set.
        string new_build_id = 1;
        // A build id which must already exist in the version sets known by the task queue. The new
        // id will be stored in the set containing this id, marking it as compatible with
        // the versions within.
        string existing_compatible_build_id = 2;
        // When set, establishes the compatible set being targeted as the overall default for the
        // queue. If a different set was the current default, the targeted set will replace it as
        // the new default.
        bool make_set_default = 3;
    }

    message MergeSets {
        // A build ID in the set whose default will become the merged set default
        string primary_set_build_id = 1;
        // A build ID in the set which will be merged into the primary set
        string secondary_set_build_id = 2;
    }

    string namespace = 1;
    // Must be set, the task queue to apply changes to. Because all workers on a given task queue
    // must have the same set of workflow & activity implementations, there is no reason to specify
    // a task queue type here.
    string task_queue = 2;
    oneof operation {
        // A new build id. This operation will create a new set which will be the new overall
        // default version for the queue, with this id as its only member. This new set is
        // incompatible with all previous sets/versions.
        //
        // (-- api-linter: core::0140::prepositions=disabled
        //     aip.dev/not-precedent: In makes perfect sense here. --)
        string add_new_build_id_in_new_default_set = 3;
        // Adds a new id to an existing compatible set, see sub-message definition for more.
        AddNewCompatibleVersion add_new_compatible_build_id = 4;
        // Promote an existing set to be the current default (if it isn't already) by targeting
        // an existing build id within it. This field's value is the extant build id.
        //
        // (-- api-linter: core::0140::prepositions=disabled
        //     aip.dev/not-precedent: Names are hard. --)
        string promote_set_by_build_id = 5;
        // Promote an existing build id within some set to be the current default for that set.
        //
        // (-- api-linter: core::0140::prepositions=disabled
        //     aip.dev/not-precedent: Within makes perfect sense here. --)
        string promote_build_id_within_set = 6;
        // Merge two existing sets together, thus declaring all build IDs in both sets compatible
        // with one another. The primary set's default will become the default for the merged set.
        // This is useful if you've accidentally declared a new ID as incompatible you meant to
        // declare as compatible. The unusual case of incomplete replication during failover could
        // also result in a split set, which this operation can repair.
        MergeSets merge_sets = 7;
    }
}
// [cleanup-wv-pre-release]
message UpdateWorkerBuildIdCompatibilityResponse {
    reserved 1;
    reserved "version_set_id";
}

// [cleanup-wv-pre-release]
message GetWorkerBuildIdCompatibilityRequest {
    string namespace = 1;
    // Must be set, the task queue to interrogate about worker id compatibility.
    string task_queue = 2;
    // Limits how many compatible sets will be returned. Specify 1 to only return the current
    // default major version set. 0 returns all sets.
    int32 max_sets = 3;
}
// [cleanup-wv-pre-release]
message GetWorkerBuildIdCompatibilityResponse {
    // Major version sets, in order from oldest to newest. The last element of the list will always
    // be the current default major version. IE: New workflows will target the most recent version
    // in that version set.
    //
    // There may be fewer sets returned than exist, if the request chose to limit this response.
    repeated temporal.api.taskqueue.v1.CompatibleVersionSet major_version_sets = 1;
}

// (-- api-linter: core::0134::request-mask-required=disabled
//     aip.dev/not-precedent: UpdateNamespace RPC doesn't follow Google API format. --)
// (-- api-linter: core::0134::request-resource-required=disabled
//     aip.dev/not-precedent: GetWorkerBuildIdCompatibilityRequest RPC doesn't follow Google API format. --)
// [cleanup-wv-pre-release]
message UpdateWorkerVersioningRulesRequest {
    // Inserts the rule to the list of assignment rules for this Task Queue.
    // The rules are evaluated in order, starting from index 0. The first
    // applicable rule will be applied and the rest will be ignored.
    message InsertBuildIdAssignmentRule {
        // Use this option to insert the rule in a particular index. By
        // default, the new rule is inserted at the beginning of the list
        // (index 0). If the given index is too larger the rule will be
        // inserted at the end of the list.
        int32 rule_index = 1;
        temporal.api.taskqueue.v1.BuildIdAssignmentRule rule = 2;
    }

    // Replaces the assignment rule at a given index.
    message ReplaceBuildIdAssignmentRule {
        int32 rule_index = 1;
        temporal.api.taskqueue.v1.BuildIdAssignmentRule rule = 2;

        // By default presence of one unconditional rule is enforced, otherwise
        // the replace operation will be rejected. Set `force` to true to
        // bypass this validation. An unconditional assignment rule:
        //   - Has no hint filter
        //   - Has no ramp
        bool force = 3;
    }

    message DeleteBuildIdAssignmentRule {
        int32 rule_index = 1;

        // By default presence of one unconditional rule is enforced, otherwise
        // the delete operation will be rejected. Set `force` to true to
        // bypass this validation. An unconditional assignment rule:
        //   - Has no hint filter
        //   - Has no ramp
        bool force = 2;
    }

    // Adds the rule to the list of redirect rules for this Task Queue. There
    // can be at most one redirect rule for each distinct Source Build ID.
    message AddCompatibleBuildIdRedirectRule {
        temporal.api.taskqueue.v1.CompatibleBuildIdRedirectRule rule = 1;
    }

    // Replaces the routing rule with the given source Build ID.
    message ReplaceCompatibleBuildIdRedirectRule {
        temporal.api.taskqueue.v1.CompatibleBuildIdRedirectRule rule = 1;
    }

    message DeleteCompatibleBuildIdRedirectRule {
        string source_build_id = 1;
    }

    // This command is intended to be used to complete the rollout of a Build
    // ID and cleanup unnecessary rules possibly created during a gradual
    // rollout. Specifically, this command will make the following changes
    // atomically:
    //  1. Adds an assignment rule (with full ramp) for the target Build ID at
    //     the end of the list.
    //  2. Removes all previously added assignment rules to the given target
    //     Build ID (if any).
    //  3. Removes any fully-ramped assignment rule for other Build IDs.
    message CommitBuildId {
        string target_build_id = 1;

        // To prevent committing invalid Build IDs, we reject the request if no
        // pollers has been seen recently for this Build ID. Use the `force`
        // option to disable this validation.
        bool force = 2;
    }

    string namespace = 1;
    string task_queue = 2;

    // A valid conflict_token can be taken from the previous
    // ListWorkerVersioningRulesResponse or UpdateWorkerVersioningRulesResponse.
    // An invalid token will cause this request to fail, ensuring that if the rules
    // for this Task Queue have been modified between the previous and current
    // operation, the request will fail instead of causing an unpredictable mutation.
    bytes conflict_token = 3;

    oneof operation {
        InsertBuildIdAssignmentRule insert_assignment_rule = 4;
        ReplaceBuildIdAssignmentRule replace_assignment_rule = 5;
        DeleteBuildIdAssignmentRule delete_assignment_rule = 6;
        AddCompatibleBuildIdRedirectRule add_compatible_redirect_rule = 7;
        ReplaceCompatibleBuildIdRedirectRule replace_compatible_redirect_rule = 8;
        DeleteCompatibleBuildIdRedirectRule delete_compatible_redirect_rule = 9;
        CommitBuildId commit_build_id = 10;
    }
}

// [cleanup-wv-pre-release]
message UpdateWorkerVersioningRulesResponse {
    repeated temporal.api.taskqueue.v1.TimestampedBuildIdAssignmentRule assignment_rules = 1;
    repeated temporal.api.taskqueue.v1.TimestampedCompatibleBuildIdRedirectRule compatible_redirect_rules = 2;

    // This value can be passed back to UpdateWorkerVersioningRulesRequest to
    // ensure that the rules were not modified between the two updates, which
    // could lead to lost updates and other confusion.
    bytes conflict_token = 3;
}

// [cleanup-wv-pre-release]
message GetWorkerVersioningRulesRequest {
    string namespace = 1;
    string task_queue = 2;
}

// [cleanup-wv-pre-release]
message GetWorkerVersioningRulesResponse {
    repeated temporal.api.taskqueue.v1.TimestampedBuildIdAssignmentRule assignment_rules = 1;
    repeated temporal.api.taskqueue.v1.TimestampedCompatibleBuildIdRedirectRule compatible_redirect_rules = 2;

    // This value can be passed back to UpdateWorkerVersioningRulesRequest to
    // ensure that the rules were not modified between this List and the Update,
    // which could lead to lost updates and other confusion.
    bytes conflict_token = 3;
}

// [cleanup-wv-pre-release]
// Deprecated. Use `DescribeTaskQueue`.
message GetWorkerTaskReachabilityRequest {
    string namespace = 1;
    // Build ids to retrieve reachability for. An empty string will be interpreted as an unversioned worker.
    // The number of build ids that can be queried in a single API call is limited.
    // Open source users can adjust this limit by setting the server's dynamic config value for
    // `limit.reachabilityQueryBuildIds` with the caveat that this call can strain the visibility store.
    repeated string build_ids = 2;

    // Task queues to retrieve reachability for. Leave this empty to query for all task queues associated with given
    // build ids in the namespace.
    // Must specify at least one task queue if querying for an unversioned worker.
    // The number of task queues that the server will fetch reachability information for is limited.
    // See the `GetWorkerTaskReachabilityResponse` documentation for more information.
    repeated string task_queues = 3;

    // Type of reachability to query for.
    // `TASK_REACHABILITY_NEW_WORKFLOWS` is always returned in the response.
    // Use `TASK_REACHABILITY_EXISTING_WORKFLOWS` if your application needs to respond to queries on closed workflows.
    // Otherwise, use `TASK_REACHABILITY_OPEN_WORKFLOWS`. Default is `TASK_REACHABILITY_EXISTING_WORKFLOWS` if left
    // unspecified.
    // See the TaskReachability docstring for information about each enum variant.
    temporal.api.enums.v1.TaskReachability reachability = 4;
}

// [cleanup-wv-pre-release]
// Deprecated. Use `DescribeTaskQueue`.
message GetWorkerTaskReachabilityResponse {
    // Task reachability, broken down by build id and then task queue.
    // When requesting a large number of task queues or all task queues associated with the given build ids in a
    // namespace, all task queues will be listed in the response but some of them may not contain reachability
    // information due to a server enforced limit. When reaching the limit, task queues that reachability information
    // could not be retrieved for will be marked with a single TASK_REACHABILITY_UNSPECIFIED entry. The caller may issue
    // another call to get the reachability for those task queues.
    //
    // Open source users can adjust this limit by setting the server's dynamic config value for
    // `limit.reachabilityTaskQueueScan` with the caveat that this call can strain the visibility store.
    repeated temporal.api.taskqueue.v1.BuildIdReachability build_id_reachability = 1;
}

// (-- api-linter: core::0134=disabled
//     aip.dev/not-precedent: Update RPCs don't follow Google API format. --)
message UpdateWorkflowExecutionRequest {
    // The namespace name of the target Workflow.
    string namespace = 1;
    // The target Workflow Id and (optionally) a specific Run Id thereof.
    // (-- api-linter: core::0203::optional=disabled
    //     aip.dev/not-precedent: false positive triggered by the word "optional" --)
    temporal.api.common.v1.WorkflowExecution workflow_execution = 2;
    // If set, this call will error if the most recent (if no Run Id is set on
    // `workflow_execution`), or specified (if it is) Workflow Execution is not
    // part of the same execution chain as this Id.
    string first_execution_run_id = 3;

    // Specifies client's intent to wait for Update results.
    // NOTE: This field works together with API call timeout which is limited by
    // server timeout (maximum wait time). If server timeout is expired before
    // user specified timeout, API call returns even if specified stage is not reached.
    // Actual reached stage will be included in the response.
    temporal.api.update.v1.WaitPolicy wait_policy = 4;

    // The request information that will be delivered all the way down to the
    // Workflow Execution.
    temporal.api.update.v1.Request request = 5;
}

message UpdateWorkflowExecutionResponse {
    // Enough information for subsequent poll calls if needed. Never null.
    temporal.api.update.v1.UpdateRef update_ref = 1;

    // The outcome of the Update if and only if the Workflow Update
    // has completed. If this response is being returned before the Update has
    // completed then this field will not be set.
    temporal.api.update.v1.Outcome outcome = 2;

    // The most advanced lifecycle stage that the Update is known to have
    // reached, where lifecycle stages are ordered
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_UNSPECIFIED <
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ADMITTED <
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED <
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED.
    // UNSPECIFIED will be returned if and only if the server's maximum wait
    // time was reached before the Update reached the stage specified in the
    // request WaitPolicy, and before the context deadline expired; clients may
    // may then retry the call as needed.
    temporal.api.enums.v1.UpdateWorkflowExecutionLifecycleStage stage = 3;
}

message StartBatchOperationRequest {
    // Namespace that contains the batch operation
    string namespace = 1;
    // Visibility query defines the the group of workflow to apply the batch operation
    // This field and `executions` are mutually exclusive
    string visibility_query = 2;
    // Job ID defines the unique ID for the batch job
    string job_id = 3;
    // Reason to perform the batch operation
    string reason = 4;
    // Executions to apply the batch operation
    // This field and `visibility_query` are mutually exclusive
    repeated temporal.api.common.v1.WorkflowExecution executions = 5;
    // Limit for the number of operations processed per second within this batch.
    // Its purpose is to reduce the stress on the system caused by batch operations, which helps to prevent system
    // overload and minimize potential delays in executing ongoing tasks for user workers.
    // Note that when no explicit limit is provided, the server will operate according to its limit defined by the
    // dynamic configuration key `worker.batcherRPS`. This also applies if the value in this field exceeds the
    // server's configured limit.
    float max_operations_per_second = 6;
    // Operation input
    oneof operation {
        temporal.api.batch.v1.BatchOperationTermination termination_operation = 10;
        temporal.api.batch.v1.BatchOperationSignal signal_operation = 11;
        temporal.api.batch.v1.BatchOperationCancellation cancellation_operation = 12;
        temporal.api.batch.v1.BatchOperationDeletion deletion_operation = 13;
        temporal.api.batch.v1.BatchOperationReset reset_operation = 14;
        temporal.api.batch.v1.BatchOperationUpdateWorkflowExecutionOptions update_workflow_options_operation = 15;
        temporal.api.batch.v1.BatchOperationUnpauseActivities unpause_activities_operation = 16;
        temporal.api.batch.v1.BatchOperationResetActivities reset_activities_operation = 17;
        temporal.api.batch.v1.BatchOperationUpdateActivityOptions update_activity_options_operation = 18;
    }
}

message StartBatchOperationResponse {
}

message StopBatchOperationRequest {
    // Namespace that contains the batch operation
    string namespace = 1;
    // Batch job id
    string job_id = 2;
    // Reason to stop a batch operation
    string reason = 3;
    // Identity of the operator
    string identity = 4;
}

message StopBatchOperationResponse {
}

message DescribeBatchOperationRequest {
    // Namespace that contains the batch operation
    string namespace = 1;
    // Batch job id
    string job_id = 2;
}

message DescribeBatchOperationResponse {
    // Batch operation type
    temporal.api.enums.v1.BatchOperationType operation_type = 1;
    // Batch job ID
    string job_id = 2;
    // Batch operation state
    temporal.api.enums.v1.BatchOperationState state = 3;
    // Batch operation start time
    google.protobuf.Timestamp start_time = 4;
    // Batch operation close time
    google.protobuf.Timestamp close_time = 5;
    // Total operation count
    int64 total_operation_count = 6;
    // Complete operation count
    int64 complete_operation_count = 7;
    // Failure operation count
    int64 failure_operation_count = 8;
    // Identity indicates the operator identity
    string identity = 9;
    // Reason indicates the reason to stop a operation
    string reason = 10;
}

message ListBatchOperationsRequest {
    // Namespace that contains the batch operation
    string namespace = 1;
    // List page size
    int32 page_size = 2;
    // Next page token
    bytes next_page_token = 3;
}

message ListBatchOperationsResponse {
    // BatchOperationInfo contains the basic info about batch operation
    repeated temporal.api.batch.v1.BatchOperationInfo operation_info = 1;
    bytes next_page_token = 2;
}

message PollWorkflowExecutionUpdateRequest {
    // The namespace of the Workflow Execution to which the Update was
    // originally issued.
    string namespace = 1;
    // The Update reference returned in the initial UpdateWorkflowExecutionResponse.
    temporal.api.update.v1.UpdateRef update_ref = 2;
    // The identity of the worker/client who is polling this Update outcome.
    string identity = 3;
    // Specifies client's intent to wait for Update results.
    // Omit to request a non-blocking poll.
    temporal.api.update.v1.WaitPolicy wait_policy = 4;
}

message PollWorkflowExecutionUpdateResponse {
    // The outcome of the update if and only if the update has completed. If
    // this response is being returned before the update has completed (e.g. due
    // to the specification of a wait policy that only waits on
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED) then this field will
    // not be set.
    temporal.api.update.v1.Outcome outcome = 1;
    // The most advanced lifecycle stage that the Update is known to have
    // reached, where lifecycle stages are ordered
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_UNSPECIFIED <
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ADMITTED <
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED <
    // UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED.
    // UNSPECIFIED will be returned if and only if the server's maximum wait
    // time was reached before the Update reached the stage specified in the
    // request WaitPolicy, and before the context deadline expired; clients may
    // may then retry the call as needed.
    temporal.api.enums.v1.UpdateWorkflowExecutionLifecycleStage stage = 2;
    // Sufficient information to address this Update.
    temporal.api.update.v1.UpdateRef update_ref = 3;
}

message PollNexusTaskQueueRequest {
    string namespace = 1;
    temporal.api.taskqueue.v1.TaskQueue task_queue = 3;
    // Unless this is the first poll, the client must pass one of the poller group IDs received in
    // `poller_group_infos` of the last the PollNexusTaskQueueResponse according to the
    // instructions. If not set, the poll is routed randomly which can cause it being blocked
    // without receiving a task while the queue actually has tasks in another server location.
    string poller_group_id = 9;
    // The identity of the client who initiated this request.
    string identity = 2;
    // A unique key for this worker instance, used for tracking worker lifecycle.
    // This is guaranteed to be unique, whereas identity is not guaranteed to be unique.
    string worker_instance_key = 8;
    // Information about this worker's build identifier and if it is choosing to use the versioning
    // feature. See the `WorkerVersionCapabilities` docstring for more.
    // Deprecated. Replaced by deployment_options.
    temporal.api.common.v1.WorkerVersionCapabilities worker_version_capabilities = 4 [deprecated = true];
    // Worker deployment options that user has set in the worker.
    temporal.api.deployment.v1.WorkerDeploymentOptions deployment_options = 6;

    // Worker info to be sent to the server.
    repeated temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 7;
}

message PollNexusTaskQueueResponse {
    // An opaque unique identifier for this task for correlating a completion request the embedded request.
    bytes task_token = 1;
    // Embedded request as translated from the incoming frontend request.
    temporal.api.nexus.v1.Request request = 2;
    // Server-advised information the SDK may use to adjust its poller count.
    temporal.api.taskqueue.v1.PollerScalingDecision poller_scaling_decision = 3;
    // This poller group ID identifies the owner of the nexus task awaiting for synchronous
    // response.
    // Corresponding `RespondNexusTaskCompleted` and `RespondNexusTaskFailed` calls should pass this
    // value for proper response routing.
    string poller_group_id = 4;
    // The weighted list of poller groups IDs that client should use for future polls to this task
    // queue. Client is expected to:
    //   1. Maintain minimum number of pollers no less than the number of groups.
    //   2. Try to assign the next poll to a group without any pending polls,
    //   3. If every group has some pending polls, assign the next poll to a group randomly
    //     according to the weights.
    repeated temporal.api.taskqueue.v1.PollerGroupInfo poller_group_infos = 5;
}

message RespondNexusTaskCompletedRequest {
    string namespace = 1;
    // The identity of the client who initiated this request.
    string identity = 2;
    // A unique identifier for this task as received via a poll response.
    bytes task_token = 3;
    // Embedded response to be translated into a frontend response.
    temporal.api.nexus.v1.Response response = 4;
    // Client must forward the poller_group_id received in PollNexusTaskQueueResponse for proper
    // routing of the response.
    string poller_group_id = 5;
}

message RespondNexusTaskCompletedResponse {
}

message RespondNexusTaskFailedRequest {
    string namespace = 1;
    // The identity of the client who initiated this request.
    string identity = 2;
    // A unique identifier for this task.
    bytes task_token = 3;
    // Deprecated. Use the failure field instead.
    temporal.api.nexus.v1.HandlerError error = 4 [deprecated = true];
    // The error the handler failed with. Must contain a NexusHandlerFailureInfo object.
    temporal.api.failure.v1.Failure failure = 5;
    // Client must forward the poller_group_id received in PollNexusTaskQueueResponse for proper
    // routing of the response.
    string poller_group_id = 6;
}

message RespondNexusTaskFailedResponse {
}

message ExecuteMultiOperationRequest {
    string namespace = 1;

    // List of operations to execute within a single workflow.
    //
    // Preconditions:
    // - The list of operations must not be empty.
    // - The workflow ids must match across operations.
    // - The only valid list of operations at this time is [StartWorkflow, UpdateWorkflow], in this order.
    //
    // Note that additional operation-specific restrictions have to be considered.
    repeated Operation operations = 2;

    // Resource ID for routing. Should match operations[0].start_workflow.workflow_id
    string resource_id = 3;

    message Operation {
        oneof operation {
            // Additional restrictions:
            // - setting `cron_schedule` is invalid
            // - setting `request_eager_execution` is invalid
            // - setting `workflow_start_delay` is invalid
            StartWorkflowExecutionRequest start_workflow = 1;

            // Additional restrictions:
            // - setting `first_execution_run_id` is invalid
            // - setting `workflow_execution.run_id` is invalid
            UpdateWorkflowExecutionRequest update_workflow = 2;
        }
    }
}

// IMPORTANT: For [StartWorkflow, UpdateWorkflow] combination ("Update-with-Start") when both
//   1. the workflow update for the requested update ID has already completed, and
//   2. the workflow for the requested workflow ID has already been closed,
// then you'll receive
//   - an update response containing the update's outcome, and
//   - a start response with a `status` field that reflects the workflow's current state.
message ExecuteMultiOperationResponse {
    repeated Response responses = 1;

    message Response {
        oneof response {
            StartWorkflowExecutionResponse start_workflow = 1;
            UpdateWorkflowExecutionResponse update_workflow = 2;
        }
    }
}

// NOTE: keep in sync with temporal.api.batch.v1.BatchOperationUpdateActivityOptions
message UpdateActivityOptionsRequest {
    // Namespace of the workflow which scheduled this activity
    string namespace = 1;
    // Execution info of the workflow which scheduled this activity
    temporal.api.common.v1.WorkflowExecution execution = 2;

    // The identity of the client who initiated this request
    string identity = 3;

    // Activity options. Partial updates are accepted and controlled by update_mask
    temporal.api.activity.v1.ActivityOptions activity_options = 4;

    // Controls which fields from `activity_options` will be applied
    google.protobuf.FieldMask update_mask = 5;

    // either activity id, activity type or update_all must be provided
    oneof activity {
        // Only activity with this ID will be updated.
        string id = 6;
        // Update all running activities of this type.
        string type = 7;
        // Update all running activities.
        bool match_all = 9;
    }

    // If set, the activity options will be restored to the default.
    // Default options are then options activity was created with.
    // They are part of the first SCHEDULE event.
    // This flag cannot be combined with any other option; if you supply
    // restore_original together with other options, the request will be rejected.
    bool restore_original = 8;
}

message UpdateActivityOptionsResponse {
    // Activity options after an update
    temporal.api.activity.v1.ActivityOptions activity_options = 1;
}

message PauseActivityRequest {
    // Namespace of the workflow which scheduled this activity.
    string namespace = 1;
    // Execution info of the workflow which scheduled this activity
    temporal.api.common.v1.WorkflowExecution execution = 2;

    // The identity of the client who initiated this request.
    string identity = 3;

    // either activity id or activity type must be provided
    oneof activity {
        // Only the activity with this ID will be paused.
        string id = 4;
        // Pause all running activities of this type.
        // Note: Experimental - the behavior of pause by activity type might change in a future release.
        string type = 5;
    }

    // Reason to pause the activity.
    string reason = 6;
}

message PauseActivityResponse {
}

message UnpauseActivityRequest {
    // Namespace of the workflow which scheduled this activity.
    string namespace = 1;
    // Execution info of the workflow which scheduled this activity
    temporal.api.common.v1.WorkflowExecution execution = 2;

    // The identity of the client who initiated this request.
    string identity = 3;

    // either activity id or activity type must be provided
    oneof activity {
        // Only the activity with this ID will be unpaused.
        string id = 4;
        // Unpause all running activities with of this type.
        string type = 5;
        // Unpause all running activities.
        bool unpause_all = 6;
    }

    // Providing this flag will also reset the number of attempts.
    bool reset_attempts = 7;

    // Providing this flag will also reset the heartbeat details.
    bool reset_heartbeat = 8;

    // If set, the activity will start at a random time within the specified jitter duration.
    google.protobuf.Duration jitter = 9;
}

message UnpauseActivityResponse {
}

// NOTE: keep in sync with temporal.api.batch.v1.BatchOperationResetActivities
message ResetActivityRequest {
    // Namespace of the workflow which scheduled this activity.
    string namespace = 1;
    // Execution info of the workflow which scheduled this activity
    temporal.api.common.v1.WorkflowExecution execution = 2;

    // The identity of the client who initiated this request.
    string identity = 3;

    // either activity id, activity type or update_all must be provided
    oneof activity {
        // Only activity with this ID will be reset.
        string id = 4;
        // Reset all running activities with of this type.
        string type = 5;
        // Reset all running activities.
        bool match_all = 10;
    }

    // Indicates that activity should reset heartbeat details.
    // This flag will be applied only to the new instance of the activity.
    bool reset_heartbeat = 6;

    // If activity is paused, it will remain paused after reset
    bool keep_paused = 7;

    // If set, and activity is in backoff, the activity will start at a random time within the specified jitter duration.
    // (unless it is paused and keep_paused is set)
    google.protobuf.Duration jitter = 8;

    // If set, the activity options will be restored to the defaults.
    // Default options are then options activity was created with.
    // They are part of the first SCHEDULE event.
    bool restore_original_options = 9;

}

message ResetActivityResponse {
}

// Keep the parameters in sync with:
//   - temporal.api.batch.v1.BatchOperationUpdateWorkflowExecutionOptions.
//   - temporal.api.workflow.v1.PostResetOperation.UpdateWorkflowOptions.
message UpdateWorkflowExecutionOptionsRequest {
    // The namespace name of the target Workflow.
    string namespace = 1;
    // The target Workflow Id and (optionally) a specific Run Id thereof.
    // (-- api-linter: core::0203::optional=disabled
    //     aip.dev/not-precedent: false positive triggered by the word "optional" --)
    temporal.api.common.v1.WorkflowExecution workflow_execution = 2;

    // Workflow Execution options. Partial updates are accepted and controlled by update_mask.
    temporal.api.workflow.v1.WorkflowExecutionOptions workflow_execution_options = 3;

    // Controls which fields from `workflow_execution_options` will be applied.
    // To unset a field, set it to null and use the update mask to indicate that it should be mutated.
    google.protobuf.FieldMask update_mask = 4;

    // Optional. The identity of the client who initiated this request.
    string identity = 5;
}

message UpdateWorkflowExecutionOptionsResponse {
    // Workflow Execution options after update.
    temporal.api.workflow.v1.WorkflowExecutionOptions workflow_execution_options = 1;
}

// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message DescribeDeploymentRequest {
    string namespace = 1;
    deployment.v1.Deployment deployment = 2;
}
// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message DescribeDeploymentResponse {
    deployment.v1.DeploymentInfo deployment_info = 1;
}

message DescribeWorkerDeploymentVersionRequest {
    string namespace = 1;
    // Deprecated. Use `deployment_version`.
    string version = 2 [deprecated = true];
    // Required.
    temporal.api.deployment.v1.WorkerDeploymentVersion deployment_version = 3;
    // Report stats for task queues which have been polled by this version.
    bool report_task_queue_stats = 4;
}

message DescribeWorkerDeploymentVersionResponse {
    temporal.api.deployment.v1.WorkerDeploymentVersionInfo worker_deployment_version_info = 1;

    // All the Task Queues that have ever polled from this Deployment version.
    repeated VersionTaskQueue version_task_queues = 2;
    // (-- api-linter: core::0123::resource-annotation=disabled --)
    message VersionTaskQueue {
        string name = 1;
        temporal.api.enums.v1.TaskQueueType type = 2;
        // Only set if `report_task_queue_stats` is set on the request.
        temporal.api.taskqueue.v1.TaskQueueStats stats = 3;
        // Task queue stats breakdown by priority key. Only contains actively used priority keys.
        // Only set if `report_task_queue_stats` is set to true in the request.
        // (-- api-linter: core::0140::prepositions=disabled
        //     aip.dev/not-precedent: "by" is used to clarify the key. --)
        map<int32, temporal.api.taskqueue.v1.TaskQueueStats> stats_by_priority_key = 4;
    }
}

message DescribeWorkerDeploymentRequest {
    string namespace = 1;
    string deployment_name = 2;
}

message DescribeWorkerDeploymentResponse {
    // This value is returned so that it can be optionally passed to APIs
    // that write to the Worker Deployment state to ensure that the state
    // did not change between this read and a future write.
    bytes conflict_token = 1;
    temporal.api.deployment.v1.WorkerDeploymentInfo worker_deployment_info = 2;
}

// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message ListDeploymentsRequest {
    string namespace = 1;
    int32 page_size = 2;
    bytes next_page_token = 3;
    // Optional. Use to filter based on exact series name match.
    string series_name = 4;
}

// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message ListDeploymentsResponse {
    bytes next_page_token = 1;
    repeated temporal.api.deployment.v1.DeploymentListInfo deployments = 2;
}

// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message SetCurrentDeploymentRequest {
    string namespace = 1;
    temporal.api.deployment.v1.Deployment deployment = 2;
    // Optional. The identity of the client who initiated this request.
    string identity = 3;
    // Optional. Use to add or remove user-defined metadata entries. Metadata entries are exposed
    // when describing a deployment. It is a good place for information such as operator name,
    // links to internal deployment pipelines, etc.
    temporal.api.deployment.v1.UpdateDeploymentMetadata update_metadata = 4;
}
// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message SetCurrentDeploymentResponse {
    temporal.api.deployment.v1.DeploymentInfo current_deployment_info = 1;
    // Info of the deployment that was current before executing this operation.
    temporal.api.deployment.v1.DeploymentInfo previous_deployment_info = 2;
}

// Set/unset the Current Version of a Worker Deployment.
message SetWorkerDeploymentCurrentVersionRequest {
    string namespace = 1;
    string deployment_name = 2;
    // Deprecated. Use `build_id`.
    string version = 3 [deprecated = true];

    // The build id of the Version that you want to set as Current.
    // Pass an empty value to set the Current Version to nil.
    // A nil Current Version represents all the unversioned workers (those with `UNVERSIONED` (or unspecified) `WorkerVersioningMode`.)
    string build_id = 7;

    // Optional. This can be the value of conflict_token from a Describe, or another Worker
    // Deployment API. Passing a non-nil conflict token will cause this request to fail if the
    // Deployment's configuration has been modified between the API call that generated the
    // token and this one.
    bytes conflict_token = 4;
    // Optional. The identity of the client who initiated this request.
    string identity = 5;
    // Optional. By default this request would be rejected if not all the expected Task Queues are
    // being polled by the new Version, to protect against accidental removal of Task Queues, or
    // worker health issues. Pass `true` here to bypass this protection.
    // The set of expected Task Queues is the set of all the Task Queues that were ever poller by
    // the existing Current Version of the Deployment, with the following exclusions:
    //   - Task Queues that are not used anymore (inferred by having empty backlog and a task
    //     add_rate of 0.)
    //   - Task Queues that are moved to another Worker Deployment (inferred by the Task Queue
    //     having a different Current Version than the Current Version of this deployment.)
    // WARNING: Do not set this flag unless you are sure that the missing task queue pollers are not
    // needed. If the request is unexpectedly rejected due to missing pollers, then that means the
    // pollers have not reached to the server yet. Only set this if you expect those pollers to
    // never arrive.
    bool ignore_missing_task_queues = 6;
    // Optional. By default this request will be rejected if no pollers have been seen for the proposed
    // Current Version, in order to protect users from routing tasks to pollers that do not exist, leading
    // to possible timeouts. Pass `true` here to bypass this protection.
    bool allow_no_pollers = 9;
}

message SetWorkerDeploymentCurrentVersionResponse {
    // This value is returned so that it can be optionally passed to APIs
    // that write to the Worker Deployment state to ensure that the state
    // did not change between this API call and a future write.
    bytes conflict_token = 1;
    // Deprecated. Use `previous_deployment_version`.
    string previous_version = 2 [deprecated = true];
    // The version that was current before executing this operation.
    // Deprecated in favor of idempotency of the API. Use `DescribeWorkerDeployment` to get the
    // Current version info before calling this API. By passing the `conflict_token` got from the
    // `DescribeWorkerDeployment` call to this API you can ensure there is no interfering changes
    // between the two calls.
    temporal.api.deployment.v1.WorkerDeploymentVersion previous_deployment_version = 3 [deprecated = true];
}

// Set/unset the Ramping Version of a Worker Deployment and its ramp percentage.
message SetWorkerDeploymentRampingVersionRequest {
    string namespace = 1;
    string deployment_name = 2;
    // Deprecated. Use `build_id`.
    string version = 3 [deprecated = true];

    // The build id of the Version that you want to ramp traffic to.
    // Pass an empty value to set the Ramping Version to nil.
    // A nil Ramping Version represents all the unversioned workers (those with `UNVERSIONED` (or unspecified) `WorkerVersioningMode`.)
    string build_id = 8;

    // Ramp percentage to set. Valid range: [0,100].
    float percentage = 4;

    // Optional. This can be the value of conflict_token from a Describe, or another Worker
    // Deployment API. Passing a non-nil conflict token will cause this request to fail if the
    // Deployment's configuration has been modified between the API call that generated the
    // token and this one.
    bytes conflict_token = 5;
    // Optional. The identity of the client who initiated this request.
    string identity = 6;
    // Optional. By default this request would be rejected if not all the expected Task Queues are
    // being polled by the new Version, to protect against accidental removal of Task Queues, or
    // worker health issues. Pass `true` here to bypass this protection.
    // The set of expected Task Queues equals to all the Task Queues ever polled from the existing
    // Current Version of the Deployment, with the following exclusions:
    //   - Task Queues that are not used anymore (inferred by having empty backlog and a task
    //     add_rate of 0.)
    //   - Task Queues that are moved to another Worker Deployment (inferred by the Task Queue
    //     having a different Current Version than the Current Version of this deployment.)
    // WARNING: Do not set this flag unless you are sure that the missing task queue poller are not
    // needed. If the request is unexpectedly rejected due to missing pollers, then that means the
    // pollers have not reached to the server yet. Only set this if you expect those pollers to
    // never arrive.
    // Note: this check only happens when the ramping version is about to change, not every time
    // that the percentage changes. Also note that the check is against the deployment's Current
    // Version, not the previous Ramping Version.
    bool ignore_missing_task_queues = 7;
    // Optional. By default this request will be rejected if no pollers have been seen for the proposed
    // Current Version, in order to protect users from routing tasks to pollers that do not exist, leading
    // to possible timeouts. Pass `true` here to bypass this protection.
    bool allow_no_pollers = 10;
}

message SetWorkerDeploymentRampingVersionResponse {
    // This value is returned so that it can be optionally passed to APIs
    // that write to the Worker Deployment state to ensure that the state
    // did not change between this API call and a future write.
    bytes conflict_token = 1;
    // Deprecated. Use `previous_deployment_version`.
    string previous_version = 2 [deprecated = true];
    // The version that was ramping before executing this operation.
    // Deprecated in favor of idempotency of the API. Use `DescribeWorkerDeployment` to get the
    // Ramping version info before calling this API. By passing the `conflict_token` got from the
    // `DescribeWorkerDeployment` call to this API you can ensure there is no interfering changes
    // between the two calls.
    temporal.api.deployment.v1.WorkerDeploymentVersion previous_deployment_version = 4 [deprecated = true];
    // The ramping version percentage before executing this operation.
    // Deprecated in favor of idempotency of the API. Use `DescribeWorkerDeployment` to get the
    // Ramping version info before calling this API. By passing the `conflict_token` got from the
    // `DescribeWorkerDeployment` call to this API you can ensure there is no interfering changes
    // between the two calls.
    float previous_percentage = 3 [deprecated = true];
}

// Creates a new WorkerDeployment.
message CreateWorkerDeploymentRequest {
    string namespace = 1;
    // The name of the Worker Deployment to create. If a Worker Deployment with
    // this name already exists, an error will be returned.
    string deployment_name = 2;

    // Optional. The identity of the client who initiated this request.
    string identity = 4;
    // A unique identifier for this create request for idempotence. Typically UUIDv4.
    string request_id = 5;
}

message CreateWorkerDeploymentResponse {
    // This value is returned so that it can be optionally passed to APIs that
    // write to the WorkerDeployment state to ensure that the state did not
    // change between this API call and a future write.
    bytes conflict_token = 1;
}

message ListWorkerDeploymentsRequest {
    string namespace = 1;
    int32 page_size = 2;
    bytes next_page_token = 3;
}

message ListWorkerDeploymentsResponse {
    bytes next_page_token = 1;
    // The list of worker deployments.
    repeated WorkerDeploymentSummary worker_deployments = 2;

    // (-- api-linter: core::0123::resource-annotation=disabled --)
    // A subset of WorkerDeploymentInfo
    message WorkerDeploymentSummary {
        string name = 1;
        google.protobuf.Timestamp create_time = 2;
        temporal.api.deployment.v1.RoutingConfig routing_config = 3;
        // Summary of the version that was added most recently in the Worker Deployment.
        temporal.api.deployment.v1.WorkerDeploymentInfo.WorkerDeploymentVersionSummary latest_version_summary = 4;
        // Summary of the current version of the Worker Deployment.
        temporal.api.deployment.v1.WorkerDeploymentInfo.WorkerDeploymentVersionSummary current_version_summary = 5;
        // Summary of the ramping version of the Worker Deployment.
        temporal.api.deployment.v1.WorkerDeploymentInfo.WorkerDeploymentVersionSummary ramping_version_summary = 6;
    }
}

// Creates a new WorkerDeploymentVersion.
message CreateWorkerDeploymentVersionRequest {
    string namespace = 1;
    // Required.
    temporal.api.deployment.v1.WorkerDeploymentVersion deployment_version = 2;

    // Optional. Contains the new worker compute configuration for the Worker
    // Deployment. Used for worker scale management.
    temporal.api.compute.v1.ComputeConfig compute_config = 4;

    // Optional. The identity of the client who initiated this request.
    string identity = 3;
    
    // A unique identifier for this create request for idempotence. Typically UUIDv4.
    // If a second request with the same ID is recieved, it is considered a successful no-op.
    // Retrying with a different request ID for the same deployment name + build ID is an error.
    string request_id = 5;
}

message CreateWorkerDeploymentVersionResponse {
}

// Used for manual deletion of Versions. User can delete a Version only when all the
// following conditions are met:
//  - It is not the Current or Ramping Version of its Deployment.
//  - It has no active pollers (none of the task queues in the Version have pollers)
//  - It is not draining (see WorkerDeploymentVersionInfo.drainage_info). This condition
//    can be skipped by passing `skip-drainage=true`.
message DeleteWorkerDeploymentVersionRequest {
    string namespace = 1;
    // Deprecated. Use `deployment_version`.
    string version = 2 [deprecated = true];
    // Required.
    temporal.api.deployment.v1.WorkerDeploymentVersion deployment_version = 5;
    // Pass to force deletion even if the Version is draining. In this case the open pinned
    // workflows will be stuck until manually moved to another version by UpdateWorkflowExecutionOptions.
    bool skip_drainage = 3;
    // Optional. The identity of the client who initiated this request.
    string identity = 4;
}

message DeleteWorkerDeploymentVersionResponse {
}

// Deletes records of (an old) Deployment. A deployment can only be deleted if
// it has no Version in it.
message DeleteWorkerDeploymentRequest {
    string namespace = 1;
    string deployment_name = 2;
    // Optional. The identity of the client who initiated this request.
    string identity = 3;
}

message DeleteWorkerDeploymentResponse {
}

// Used to update the compute config of a Worker Deployment Version.
message UpdateWorkerDeploymentVersionComputeConfigRequest {
    string namespace = 1;

    // Required.
    temporal.api.deployment.v1.WorkerDeploymentVersion deployment_version = 2;

    // Optional. Contains the compute config scaling groups to add or update for the Worker
    // Deployment.
    map<string, temporal.api.compute.v1.ComputeConfigScalingGroupUpdate> compute_config_scaling_groups = 6;

    // Optional. Contains the compute config scaling groups to remove from the Worker Deployment.
    repeated string remove_compute_config_scaling_groups = 7;

    // Optional. The identity of the client who initiated this request.
    string identity = 3;

    // A unique identifier for this create request for idempotence. Typically UUIDv4.
    // If a second request with the same ID is recieved, it is considered a successful no-op.
    // Retrying with a different request ID for the same deployment name + build ID is an error.
    string request_id = 4;
}

message UpdateWorkerDeploymentVersionComputeConfigResponse {
}

// Used to validate the compute config without attaching it to a Worker Deployment Version.
message ValidateWorkerDeploymentVersionComputeConfigRequest {
    string namespace = 1;

    // Required.
    temporal.api.deployment.v1.WorkerDeploymentVersion deployment_version = 2;

    // Optional. Contains the compute config scaling groups to add or update for the Worker
    // Deployment.
    map<string, temporal.api.compute.v1.ComputeConfigScalingGroupUpdate> compute_config_scaling_groups = 6;

    // Optional. Contains the compute config scaling groups to remove from the Worker Deployment.
    repeated string remove_compute_config_scaling_groups = 7;

    // Optional. The identity of the client who initiated this request.
    string identity = 3;
}

message ValidateWorkerDeploymentVersionComputeConfigResponse {
}

// Used to update the user-defined metadata of a Worker Deployment Version.
message UpdateWorkerDeploymentVersionMetadataRequest {
    string namespace = 1;
    // Deprecated. Use `deployment_version`.
    string version = 2 [deprecated = true];
    // Required.
    temporal.api.deployment.v1.WorkerDeploymentVersion deployment_version = 5;
    map<string, temporal.api.common.v1.Payload> upsert_entries = 3;
    // List of keys to remove from the metadata.
    repeated string remove_entries = 4;
    // Optional. The identity of the client who initiated this request.
    string identity = 6;
}

message UpdateWorkerDeploymentVersionMetadataResponse {
    // Full metadata after performing the update.
    temporal.api.deployment.v1.VersionMetadata metadata = 1;
}

// Update the ManagerIdentity of a Worker Deployment.
message SetWorkerDeploymentManagerRequest {
    string namespace = 1;
    string deployment_name = 2;

    oneof new_manager_identity {
      // Arbitrary value for `manager_identity`.
      // Empty will unset the field.
      string manager_identity = 3;

      // True will set `manager_identity` to `identity`.
      bool self = 4;
    }

    // Optional. This can be the value of conflict_token from a Describe, or another Worker
    // Deployment API. Passing a non-nil conflict token will cause this request to fail if the
    // Deployment's configuration has been modified between the API call that generated the
    // token and this one.
    bytes conflict_token = 5;

    // Required. The identity of the client who initiated this request.
    string identity = 6;
}

message SetWorkerDeploymentManagerResponse {
    // This value is returned so that it can be optionally passed to APIs
    // that write to the Worker Deployment state to ensure that the state
    // did not change between this API call and a future write.
    bytes conflict_token = 1;

    // What the `manager_identity` field was before this change.
    // Deprecated in favor of idempotency of the API. Use `DescribeWorkerDeployment` to get the
    // manager identity before calling this API. By passing the `conflict_token` got from the
    // `DescribeWorkerDeployment` call to this API you can ensure there is no interfering changes
    // between the two calls.
    string previous_manager_identity = 2 [deprecated = true];
}

// Returns the Current Deployment of a deployment series.
// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message GetCurrentDeploymentRequest {
    string namespace = 1;
    string series_name = 2;
}
// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message GetCurrentDeploymentResponse {
    temporal.api.deployment.v1.DeploymentInfo current_deployment_info = 1;
}

// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message GetDeploymentReachabilityRequest {
    string namespace = 1;
    temporal.api.deployment.v1.Deployment deployment = 2;
}

// [cleanup-wv-pre-release] Pre-release deployment APIs, clean up later
message GetDeploymentReachabilityResponse {
    temporal.api.deployment.v1.DeploymentInfo deployment_info = 1;
    enums.v1.DeploymentReachability reachability = 2;
    // Reachability level might come from server cache. This timestamp specifies when the value
    // was actually calculated.
    google.protobuf.Timestamp last_update_time = 3;
}

message CreateWorkflowRuleRequest {
    string namespace = 1;

    // The rule specification .
    temporal.api.rules.v1.WorkflowRuleSpec spec = 2;

    // If true, the rule will be applied to the currently running workflows via batch job.
    // If not set , the rule will only be applied when triggering condition is satisfied.
    // visibility_query in the rule will be used to select the workflows to apply the rule to.
    bool force_scan = 3;

    // Used to de-dupe requests. Typically should be UUID.
    string request_id = 4;

    // Identity of the actor who created the rule. Will be stored with the rule.
    string identity = 5;

    // Rule description.Will be stored with the rule.
    string description = 6;
}

message CreateWorkflowRuleResponse {
    // Created rule.
    temporal.api.rules.v1.WorkflowRule  rule = 1;

    // Batch Job ID if force-scan flag was provided. Otherwise empty.
    string job_id = 2;
}

message DescribeWorkflowRuleRequest {
    string namespace = 1;
    // User-specified ID of the rule to read. Unique within the namespace.
    string rule_id = 2;
}

message DescribeWorkflowRuleResponse {
    // The rule that was read.
    temporal.api.rules.v1.WorkflowRule rule = 1;
}

message DeleteWorkflowRuleRequest {
    string namespace = 1;

    // ID of the rule to delete. Unique within the namespace.
    string rule_id = 2;
}

message DeleteWorkflowRuleResponse {
}

message ListWorkflowRulesRequest {
    string namespace = 1;
    bytes next_page_token = 2;
}

message ListWorkflowRulesResponse {
    repeated temporal.api.rules.v1.WorkflowRule rules = 1;
    bytes next_page_token = 2;
}

message TriggerWorkflowRuleRequest {
    string namespace = 1;

    // Execution info of the workflow which scheduled this activity
    temporal.api.common.v1.WorkflowExecution execution = 2;

    // Either provide id of existing rule, or rule specification
    oneof rule {
        string id = 4;
        // Note: Rule ID and expiration date are not used in the trigger request.
        temporal.api.rules.v1.WorkflowRuleSpec spec = 5;
    }

    // The identity of the client who initiated this request
    string identity = 3;
}

message TriggerWorkflowRuleResponse {
    // True is the rule was applied, based on the rule conditions (predicate/visibility_query).
    bool applied = 1;
}
message RecordWorkerHeartbeatRequest {
    // Namespace this worker belongs to.
    string namespace = 1;

    // The identity of the client who initiated this request.
    string identity = 2;

    repeated temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 3;
    // Resource ID for routing. Contains the worker grouping key.
    string resource_id = 4;
}

message RecordWorkerHeartbeatResponse {

}

message ListWorkersRequest {
    string namespace = 1;
    int32 page_size = 2;
    bytes next_page_token = 3;

    // `query` in ListWorkers is used to filter workers based on worker attributes.
    // Supported attributes:
    //* WorkerInstanceKey
    //* WorkerIdentity
    //* HostName
    //* TaskQueue
    //* DeploymentName
    //* BuildId
    //* SdkName
    //* SdkVersion
    //* StartTime
    //* Status
    string query = 4;
}

message ListWorkersResponse {
    // Deprecated: Use workers instead. This field returns full WorkerInfo which
    // includes expensive runtime metrics. We will stop populating this field in the future.
    repeated temporal.api.worker.v1.WorkerInfo workers_info = 1 [deprecated = true];

    // Limited worker information.
    repeated temporal.api.worker.v1.WorkerListInfo workers = 3;

    // Next page token
    bytes next_page_token = 2;
}

message UpdateTaskQueueConfigRequest {
    message RateLimitUpdate {
        // Rate Limit to be updated
        temporal.api.taskqueue.v1.RateLimit rate_limit = 1;
        // Reason for why the rate limit was set.
        string reason = 2;
    }

    string namespace = 1;
    string identity = 2;
    // Selects the task queue to update.
    string task_queue = 3;
    temporal.api.enums.v1.TaskQueueType task_queue_type = 4;
    // Update to queue-wide rate limit.
    // If not set, this configuration is unchanged.
    // NOTE: A limit set by the worker is overriden; and restored again when reset.
    // If the `rate_limit` field in the `RateLimitUpdate` is missing, remove the existing rate limit.
    RateLimitUpdate update_queue_rate_limit = 5;
    // Update to the default fairness key rate limit.
    // If not set, this configuration is unchanged.
    // If the `rate_limit` field in the `RateLimitUpdate` is missing, remove the existing rate limit.
    RateLimitUpdate update_fairness_key_rate_limit_default = 6;
    // If set, overrides the fairness weight for each specified fairness key.
    // Fairness keys not listed in this map will keep their existing overrides (if any).
    map<string, float> set_fairness_weight_overrides = 7;
    // If set, removes any existing fairness weight overrides for each specified fairness key.
    // Fairness weights for corresponding keys fall back to the values set during task creation (if any),
    // or to the default weight of 1.0.
    repeated string unset_fairness_weight_overrides = 8;
}

message UpdateTaskQueueConfigResponse {
    temporal.api.taskqueue.v1.TaskQueueConfig config = 1;
}

message FetchWorkerConfigRequest {
    // Namespace this worker belongs to.
    string namespace = 1;

    // The identity of the client who initiated this request.
    string identity = 2;

    // Reason for sending worker command, can be used for audit purpose.
    string reason = 3;

    // Defines which workers should receive this command.
    // only single worker is supported at this time.
    temporal.api.common.v1.WorkerSelector selector = 6;
    // Resource ID for routing. Contains the worker grouping key.
    string resource_id = 7;
}

message FetchWorkerConfigResponse {
    // The worker configuration.
    temporal.api.sdk.v1.WorkerConfig worker_config = 1;
}

message UpdateWorkerConfigRequest {
    // Namespace this worker belongs to.
    string namespace = 1;

    // The identity of the client who initiated this request.
    string identity = 2;

    // Reason for sending worker command, can be used for audit purpose.
    string reason = 3;

    // Partial updates are accepted and controlled by update_mask.
    // The worker configuration to set.
    temporal.api.sdk.v1.WorkerConfig worker_config = 4;

    // Controls which fields from `worker_config` will be applied
    google.protobuf.FieldMask update_mask = 5;

    // Defines which workers should receive this command.
    temporal.api.common.v1.WorkerSelector selector = 6;
    // Resource ID for routing. Contains the worker grouping key.
    string resource_id = 7;
}

message UpdateWorkerConfigResponse {
    oneof response {
        // The worker configuration. Will be returned if the command was sent to a single worker.
        temporal.api.sdk.v1.WorkerConfig worker_config = 1;

        // Once we support sending update to a multiple workers - it will be converted into a batch job, and job id will be returned.
    }
}

message DescribeWorkerRequest {
    // Namespace this worker belongs to.
    string namespace = 1;

    // Worker instance key to describe.
    string worker_instance_key = 2;
}

message DescribeWorkerResponse {
    temporal.api.worker.v1.WorkerInfo worker_info = 1;
}

// Request to pause a workflow execution.
message PauseWorkflowExecutionRequest {
    // Namespace of the workflow to pause.
    string namespace = 1;
    // ID of the workflow execution to be paused. Required.
    string workflow_id = 2;
    // Run ID of the workflow execution to be paused. Optional. If not provided, the current run of the workflow will be paused.
    string run_id = 3;
    // The identity of the client who initiated this request.
    string identity = 4;
    // Reason to pause the workflow execution.
    string reason = 5;
    // A unique identifier for this pause request for idempotence. Typically UUIDv4.
    string request_id = 6;
}

// Response to a successful PauseWorkflowExecution request.
message PauseWorkflowExecutionResponse { }

message UnpauseWorkflowExecutionRequest {
    // Namespace of the workflow to unpause.
    string namespace = 1;
    // ID of the workflow execution to be paused. Required.
    string workflow_id = 2;
    // Run ID of the workflow execution to be paused. Optional. If not provided, the current run of the workflow will be paused.
    string run_id = 3;
    // The identity of the client who initiated this request.
    string identity = 4;
    // Reason to unpause the workflow execution.
    string reason = 5;
    // A unique identifier for this unpause request for idempotence. Typically UUIDv4.
    string request_id = 6;
}

// Response to a successful UnpauseWorkflowExecution request.
message UnpauseWorkflowExecutionResponse { }

message StartActivityExecutionRequest {
    string namespace = 1;
    // The identity of the client who initiated this request
    string identity = 2;
    // A unique identifier for this start request. Typically UUIDv4.
    string request_id = 3;

    // Identifier for this activity. Required. This identifier should be meaningful in the user's
    // own system. It must be unique among activities in the same namespace, subject to the rules
    // imposed by id_reuse_policy and id_conflict_policy.
    string activity_id = 4;

    // The type of the activity, a string that corresponds to a registered activity on a worker.
    temporal.api.common.v1.ActivityType activity_type = 5;

    // Task queue to schedule this activity on.
    temporal.api.taskqueue.v1.TaskQueue task_queue = 6;
    // Indicates how long the caller is willing to wait for an activity completion. Limits how long
    // retries will be attempted. Either this or `start_to_close_timeout` must be specified.
    //
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "to" is used to indicate interval. --)
    google.protobuf.Duration schedule_to_close_timeout = 7;
    // Limits time an activity task can stay in a task queue before a worker picks it up. This
    // timeout is always non retryable, as all a retry would achieve is to put it back into the same
    // queue. Defaults to `schedule_to_close_timeout` if not specified.
    //
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "to" is used to indicate interval. --)
    google.protobuf.Duration schedule_to_start_timeout = 8;
    // Maximum time an activity is allowed to execute after being picked up by a worker. This
    // timeout is always retryable. Either this or `schedule_to_close_timeout` must be
    // specified.
    //
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "to" is used to indicate interval. --)
    google.protobuf.Duration start_to_close_timeout = 9;
    // Maximum permitted time between successful worker heartbeats.
    google.protobuf.Duration heartbeat_timeout = 10;
    // The retry policy for the activity. Will never exceed `schedule_to_close_timeout`.
    temporal.api.common.v1.RetryPolicy retry_policy = 11;

    // Serialized arguments to the activity. These are passed as arguments to the activity function.
    temporal.api.common.v1.Payloads input = 12;

    // Defines whether to allow re-using the activity id from a previously *closed* activity.
    // The default policy is ACTIVITY_ID_REUSE_POLICY_ALLOW_DUPLICATE.
    temporal.api.enums.v1.ActivityIdReusePolicy id_reuse_policy = 13;
    // Defines how to resolve an activity id conflict with a *running* activity.
    // The default policy is ACTIVITY_ID_CONFLICT_POLICY_FAIL.
    temporal.api.enums.v1.ActivityIdConflictPolicy id_conflict_policy = 14;

    // Search attributes for indexing.
    temporal.api.common.v1.SearchAttributes search_attributes = 15;
    // Header for context propagation and tracing purposes.
    temporal.api.common.v1.Header header = 16;
    // Metadata for use by user interfaces to display the fixed as-of-start summary and details of the activity.
    temporal.api.sdk.v1.UserMetadata user_metadata = 17;
    // Priority metadata.
    temporal.api.common.v1.Priority priority = 18;
    // Callbacks to be called by the server when this activity reaches a terminal state.
    // Callback addresses must be whitelisted in the server's dynamic configuration.
    repeated temporal.api.common.v1.Callback completion_callbacks = 19;
    // Links to be associated with the activity. Callbacks may also have associated links;
    // links already included with a callback should not be duplicated here.
    repeated temporal.api.common.v1.Link links = 20;
    // Options for handling conflicts when using ACTIVITY_ID_CONFLICT_POLICY_USE_EXISTING.
    temporal.api.common.v1.OnConflictOptions on_conflict_options = 21;
    // Time to wait before dispatching the first activity task. This delay is not applied to retry attempts.
    google.protobuf.Duration start_delay = 22;
}

message StartActivityExecutionResponse {
    // The run ID of the activity that was started - or used (via ACTIVITY_ID_CONFLICT_POLICY_USE_EXISTING).
    string run_id = 1;
    // If true, a new activity was started.
    bool started = 2;
    // Link to the started activity.
    temporal.api.common.v1.Link link = 3;
}

message DescribeActivityExecutionRequest {
    string namespace = 1;
    string activity_id = 2;
    // Activity run ID. If empty the request targets the latest run.
    string run_id = 3;
    // Include the input field in the response.
    bool include_input = 4;
    // Include the outcome (result/failure) in the response if the activity has completed.
    bool include_outcome = 5;
    // Token from a previous DescribeActivityExecutionResponse. If present, long-poll until activity
    // state changes from the state encoded in this token. If absent, return current state immediately.
    // If present, run_id must also be present.
    // Note that activity state may change multiple times between requests, therefore it is not
    // guaranteed that a client making a sequence of long-poll requests will see a complete
    // sequence of state changes.
    bytes long_poll_token = 6;
}

message DescribeActivityExecutionResponse {
    // The run ID of the activity, useful when run_id was not specified in the request.
    string run_id = 1;

    // Information about the activity execution.
    temporal.api.activity.v1.ActivityExecutionInfo info = 2;

    // Serialized activity input, passed as arguments to the activity function.
    // Only set if include_input was true in the request.
    temporal.api.common.v1.Payloads input = 3;

    // Only set if the activity is completed and include_outcome was true in the request.
    temporal.api.activity.v1.ActivityExecutionOutcome outcome = 4;

    // Token for follow-on long-poll requests. Absent only if the activity is complete.
    bytes long_poll_token = 5;

    // Callbacks attached to this activity execution and their current state.
    repeated temporal.api.activity.v1.CallbackInfo callbacks = 6;
}

message PollActivityExecutionRequest {
    string namespace = 1;
    string activity_id = 2;
    // Activity run ID. If empty the request targets the latest run.
    string run_id = 3;
}

message PollActivityExecutionResponse {
    // The run ID of the activity, useful when run_id was not specified in the request.
    string run_id = 1;

    temporal.api.activity.v1.ActivityExecutionOutcome outcome = 2;
}

message ListActivityExecutionsRequest {
    string namespace = 1;
    // Max number of executions to return per page.
    int32 page_size = 2;
    // Token returned in ListActivityExecutionsResponse.
    bytes next_page_token = 3;
    // Visibility query, see https://docs.temporal.io/list-filter for the syntax.
    string query = 4;
}

message ListActivityExecutionsResponse {
    repeated temporal.api.activity.v1.ActivityExecutionListInfo executions = 1;
    // Token to use to fetch the next page. If empty, there is no next page.
    bytes next_page_token = 2;
}

message StartNexusOperationExecutionRequest {
    string namespace = 1;
    // The identity of the client who initiated this request.
    string identity = 2;
    // A unique identifier for this caller-side start request. Typically UUIDv4.
    // StartOperation requests sent to the handler will use a server-generated request ID.
    string request_id = 3;
    // Identifier for this operation. This is a caller-side ID, distinct from any internal
    // operation identifiers generated by the handler. Must be unique among operations in the
    // same namespace, subject to the rules imposed by id_reuse_policy and id_conflict_policy.
    string operation_id = 4;
    // Endpoint name, resolved to a URL via the cluster's endpoint registry.
    string endpoint = 5;
    // Service name.
    string service = 6;
    // Operation name.
    string operation = 7;

    // Schedule-to-close timeout for this operation.
    // Indicates how long the caller is willing to wait for operation completion.
    // Calls are retried internally by the server.
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "to" is used to indicate interval. --)
    google.protobuf.Duration schedule_to_close_timeout = 8;

    // Schedule-to-start timeout for this operation.
    // Indicates how long the caller is willing to wait for the operation to be started (or completed if synchronous)
    // by the handler.
    // If not set or zero, no schedule-to-start timeout is enforced.
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "to" is used to indicate interval. --)
    google.protobuf.Duration schedule_to_start_timeout = 9;

    // Start-to-close timeout for this operation.
    // Indicates how long the caller is willing to wait for an asynchronous operation to complete after it has been
    // started. Synchronous operations ignore this timeout.
    // If not set or zero, no start-to-close timeout is enforced.
    // (-- api-linter: core::0140::prepositions=disabled
    //     aip.dev/not-precedent: "to" is used to indicate interval. --)
    google.protobuf.Duration start_to_close_timeout = 10;

    // Serialized input to the operation. Passed as the request payload.
    temporal.api.common.v1.Payload input = 11;

    // Defines whether to allow re-using the operation id from a previously *closed* operation.
    // The default policy is NEXUS_OPERATION_ID_REUSE_POLICY_ALLOW_DUPLICATE.
    temporal.api.enums.v1.NexusOperationIdReusePolicy id_reuse_policy = 12;
    // Defines how to resolve an operation id conflict with a *running* operation.
    // The default policy is NEXUS_OPERATION_ID_CONFLICT_POLICY_FAIL.
    temporal.api.enums.v1.NexusOperationIdConflictPolicy id_conflict_policy = 13;

    // Search attributes for indexing.
    temporal.api.common.v1.SearchAttributes search_attributes = 14;
    // Header to attach to the Nexus request.
    // Users are responsible for encrypting sensitive data in this header as it is stored in workflow history and
    // transmitted to external services as-is.
    // This is useful for propagating tracing information.
    // Note these headers are not the same as Temporal headers on internal activities and child workflows, these are
    // transmitted to Nexus operations that may be external and are not traditional payloads.
    map<string, string> nexus_header = 15;
    // Metadata for use by user interfaces to display the fixed as-of-start summary and details of the operation.
    temporal.api.sdk.v1.UserMetadata user_metadata = 16;
}

message StartNexusOperationExecutionResponse {
    // The run ID of the operation that was started - or used (via NEXUS_OPERATION_ID_CONFLICT_POLICY_USE_EXISTING).
    string run_id = 1;
    // If true, a new operation was started.
    bool started = 2;
}

message DescribeNexusOperationExecutionRequest {
    string namespace = 1;
    string operation_id = 2;
    // Operation run ID. If empty the request targets the latest run.
    string run_id = 3;
    // Include the input field in the response.
    bool include_input = 4;
    // Include the outcome (result/failure) in the response if the operation has completed.
    bool include_outcome = 5;
    // Token from a previous DescribeNexusOperationExecutionResponse. If present, this RPC will long-poll until operation
    // state changes from the state encoded in this token. If absent, return current state immediately.
    // If present, run_id must also be present.
    // Note that operation state may change multiple times between requests, therefore it is not
    // guaranteed that a client making a sequence of long-poll requests will see a complete
    // sequence of state changes.
    bytes long_poll_token = 6;
}

message DescribeNexusOperationExecutionResponse {
    // The run ID of the operation, useful when run_id was not specified in the request.
    string run_id = 1;

    // Information about the operation.
    temporal.api.nexus.v1.NexusOperationExecutionInfo info = 2;

    // Serialized operation input, passed as the request payload.
    // Only set if include_input was true in the request.
    temporal.api.common.v1.Payload input = 3;

    // Only set if the operation is completed and include_outcome was true in the request.
    oneof outcome {
        // The result if the operation completed successfully.
        temporal.api.common.v1.Payload result = 4;
        // The failure if the operation completed unsuccessfully.
        temporal.api.failure.v1.Failure failure = 5;
    }

    // Token for follow-on long-poll requests. Absent only if the operation is complete.
    bytes long_poll_token = 6;
}

message PollNexusOperationExecutionRequest {
    string namespace = 1;
    string operation_id = 2;
    // Operation run ID. If empty the request targets the latest run.
    string run_id = 3;

    // Stage to wait for. The operation may be in a more advanced stage when the poll is unblocked.
    temporal.api.enums.v1.NexusOperationWaitStage wait_stage = 4;
}

message PollNexusOperationExecutionResponse {
    // The run ID of the operation, useful when run_id was not specified in the request.
    string run_id = 1;

    // The current stage of the operation. May be more advanced than the stage requested in the poll.
    temporal.api.enums.v1.NexusOperationWaitStage wait_stage = 2;

    // Operation token. Only populated for asynchronous operations after a successful StartOperation call.
    string operation_token = 3;

    // The operation outcome, available if the operation is in a closed state.
    oneof outcome {
        // The result if the operation completed successfully.
        temporal.api.common.v1.Payload result = 4;
        // The failure if the operation completed unsuccessfully.
        temporal.api.failure.v1.Failure failure = 5;
    }
}

message ListNexusOperationExecutionsRequest {
    string namespace = 1;
    // Max number of operations to return per page.
    int32 page_size = 2;
    // Token returned in ListNexusOperationExecutionsResponse.
    bytes next_page_token = 3;
    // Visibility query, see https://docs.temporal.io/list-filter for the syntax.
    // Search attributes that are avaialble for Nexus operations include:
    // - OperationId
    // - RunId
    // - Endpoint
    // - Service
    // - Operation
    // - RequestId
    // - StartTime
    // - ExecutionTime
    // - CloseTime
    // - ExecutionStatus
    // - ExecutionDuration
    // - StateTransitionCount
    string query = 4;
}

message ListNexusOperationExecutionsResponse {
    repeated temporal.api.nexus.v1.NexusOperationExecutionListInfo operations = 1;
    // Token to use to fetch the next page. If empty, there is no next page.
    bytes next_page_token = 2;
}

message CountActivityExecutionsRequest {
    string namespace = 1;
    // Visibility query, see https://docs.temporal.io/list-filter for the syntax.
    string query = 2;
}

message CountActivityExecutionsResponse {
    // If `query` is not grouping by any field, the count is an approximate number
    // of activities that match the query.
    // If `query` is grouping by a field, the count is simply the sum of the counts
    // of the groups returned in the response. This number can be smaller than the
    // total number of activities matching the query.
    int64 count = 1;

    // Contains the groups if the request is grouping by a field.
    // The list might not be complete, and the counts of each group is approximate.
    repeated AggregationGroup groups = 2;

    message AggregationGroup {
        repeated temporal.api.common.v1.Payload group_values = 1;
        int64 count = 2;
    }
}

message CountNexusOperationExecutionsRequest {
    string namespace = 1;
    // Visibility query, see https://docs.temporal.io/list-filter for the syntax.
    // See also ListNexusOperationExecutionsRequest for search attributes available for Nexus operations.
    string query = 2;
}

message CountNexusOperationExecutionsResponse {
    // If `query` is not grouping by any field, the count is an approximate number
    // of operations that match the query.
    // If `query` is grouping by a field, the count is simply the sum of the counts
    // of the groups returned in the response. This number can be smaller than the
    // total number of operations matching the query.
    int64 count = 1;

    // Contains the groups if the request is grouping by a field.
    // The list might not be complete, and the counts of each group is approximate.
    repeated AggregationGroup groups = 2;

    message AggregationGroup {
        repeated temporal.api.common.v1.Payload group_values = 1;
        int64 count = 2;
    }
}

message RequestCancelActivityExecutionRequest {
    string namespace = 1;
    string activity_id = 2;
    // Activity run ID, targets the latest run if run_id is empty.
    string run_id = 3;
    // The identity of the worker/client.
    string identity = 4;
    // Used to de-dupe cancellation requests.
    string request_id = 5;
    // Reason for requesting the cancellation, recorded and available via the PollActivityExecution API.
    // Not propagated to a worker if an activity attempt is currently running.
    string reason = 6;
}

message RequestCancelActivityExecutionResponse {
}

message TerminateActivityExecutionRequest {
    string namespace = 1;
    string activity_id = 2;
    // Activity run ID, targets the latest run if run_id is empty.
    string run_id = 3;
    // The identity of the worker/client.
    string identity = 4;
    // Used to de-dupe termination requests.
    string request_id = 5;
    // Reason for requesting the termination, recorded in in the activity's result failure outcome.
    string reason = 6;
}

message TerminateActivityExecutionResponse {
}

message DeleteActivityExecutionRequest {
    string namespace = 1;
    string activity_id = 2;
    // Activity run ID, targets the latest run if run_id is empty.
    string run_id = 3;
}

message DeleteActivityExecutionResponse {
}

message RequestCancelNexusOperationExecutionRequest {
    string namespace = 1;
    string operation_id = 2;
    // Operation run ID, targets the latest run if empty.
    string run_id = 3;
    // The identity of the client who initiated this request.
    string identity = 4;
    // Used to de-dupe cancellation requests.
    string request_id = 5;
    // Reason for requesting the cancellation, recorded and available via the DescribeNexusOperationExecution API.
    string reason = 6;
}

message RequestCancelNexusOperationExecutionResponse {
}

message TerminateNexusOperationExecutionRequest {
    string namespace = 1;
    string operation_id = 2;
    // Operation run ID, targets the latest run if empty.
    string run_id = 3;
    // The identity of the client who initiated this request.
    string identity = 4;
    // Used to de-dupe termination requests.
    string request_id = 5;
    // Reason for requesting the termination, recorded in the operation's result failure outcome.
    string reason = 6;
}

message TerminateNexusOperationExecutionResponse {
}

message DeleteNexusOperationExecutionRequest {
    string namespace = 1;
    string operation_id = 2;
    // Operation run ID, targets the latest run if empty.
    string run_id = 3;
}

message DeleteNexusOperationExecutionResponse {
}
